The Computer Vision Workshop

Book description

Explore the potential of deep learning techniques in computer vision applications using the Python ecosystem, and build real-time systems for detecting human behavior

Key Features

  • Understand OpenCV and select the right algorithm to solve real-world problems
  • Discover techniques for image and video processing
  • Learn how to apply face recognition in videos to automatically extract key information

Book Description

Computer Vision (CV) has become an important aspect of AI technology. From driverless cars to medical diagnostics and monitoring the health of crops to fraud detection in banking, computer vision is used across all domains to automate tasks. The Computer Vision Workshop will help you understand how computers master the art of processing digital images and videos to mimic human activities.

Starting with an introduction to the OpenCV library, you'll learn how to write your first script using basic image processing operations. You'll then get to grips with essential image and video processing techniques such as histograms, contours, and face processing. As you progress, you'll become familiar with advanced computer vision and deep learning concepts, such as object detection, tracking, and recognition, and finally shift your focus from 2D to 3D visualization. This CV course will enable you to experiment with camera calibration and explore both passive and active canonical 3D reconstruction methods.

By the end of this book, you'll have developed the practical skills necessary for building powerful applications to solve computer vision problems.

What you will learn

  • Access and manipulate pixels in OpenCV using BGR and grayscale images
  • Create histograms to better understand image content
  • Use contours for shape analysis, object detection, and recognition
  • Track objects in videos using a variety of trackers available in OpenCV
  • Discover how to apply face recognition tasks using computer vision techniques
  • Visualize 3D objects in point clouds and polygon meshes using Open3D

Who this book is for

If you are a researcher, developer, or data scientist looking to automate everyday tasks using computer vision, this workshop is for you. A basic understanding of Python and deep learning will help you to get the most out of this workshop.

Publisher resources

Download Example Code

Table of contents

  1. The Computer Vision Workshop
  2. Preface
    1. About the Book
      1. Audience
      2. About the Chapters
      3. Conventions
      4. Code Presentation
      5. Setting up Your Environment
      6. Downloading Anaconda Installer
      7. Installing Anaconda on Windows
      8. Installing Anaconda on Linux
      9. Installing Anaconda on macOS X
      10. Installing Other Libraries
      11. Accessing the Code Files
  3. 1. Basics of Image Processing
    1. Introduction
    2. NumPy Arrays
      1. Exercise 1.01: Creating NumPy Arrays
    3. Pixels in Images
      1. Pixel Location – Image Coordinate System
      2. Image Properties
        1. Size of the Image
        2. Color Spaces and Channels
      3. Pixel Values
    4. Introduction to OpenCV
      1. Images in OpenCV
      2. Important OpenCV Functions
      3. Exercise 1.02: Reading, Processing, and Writing an Image
      4. Using Matplotlib to Display Images
      5. Accessing and Manipulating Pixels
      6. Exercise 1.03: Creating a Water Effect
      7. Activity 1.01: Mirror Effect with a Twist
    5. Summary
  4. 2. Common Operations When Working with Images
    1. Introduction
    2. Geometric Transformations
      1. Image Translation
      2. Exercise 2.01: Translation Using NumPy
      3. Image Rotation
        1. Finding the Rotation Matrix
        2. Finding the Size of the Output Image
      4. Image Resizing
      5. Affine Transformation
      6. Exercise 2.02: Working with Affine Transformation
      7. Perspective Transformation
      8. Exercise 2.03: Perspective Transformation
    3. Image Arithmetic
      1. Image Addition
      2. Exercise 2.04: Performing Image Addition
      3. Image Multiplication
      4. Exercise 2.05: Image Multiplication
    4. Binary Images
      1. Exercise 2.06: Converting an Image into a Binary Image
      2. Bitwise Operations on Images
      3. Exercise 2.07: Chess Pieces
      4. Masking
      5. Activity 2.01: Masking Using Binary Images
    5. Summary
  5. 3. Working with Histograms
    1. Introduction
    2. Introduction to Matplotlib
      1. Displaying Images with Matplotlib
      2. Plotting Histograms with Matplotlib
      3. Exercise 3.01: Plotting a Sample Image and Its Histogram with 256 bins
      4. Exercise 3.02: Plotting a Sample Image and Its Histogram with 10 bins
    3. Histograms with OpenCV
      1. User-Selected ROI
      2. Exercise 3.03: Creating a Mask Image Using a User-Selected ROI
      3. A Comparison of Some Sample Histograms
      4. What Is Histogram Equalization?
      5. Exercise 3.04: Histogram Equalization of a Grayscale Image
      6. Contrast Limited Adaptive Histogram Equalization (CLAHE)
      7. Exercise 3.05: Application of CLAHE on a Grayscale Image
      8. Activity 3.01: Enhancing Images Using Histogram Equalization and CLAHE
      9. Exercise 3.06: Histogram Equalization in the BGR Color Space
      10. The Histogram Equalization of Color Images Using the HSV and LAB Color Spaces
      11. Exercise 3.07: Histogram Equalization in the HSV Color Space
      12. Exercise 3.08: Histogram Equalization in the LAB Color Space
      13. Activity 3.02: Image Enhancement in a User-Defined ROI
    4. Summary
  6. 4. Working with contours
    1. Introduction
    2. Contours – Basic Detection and Plotting
      1. Exercise 4.01: Detecting Shapes and Displaying Them on BGR Images
      2. Exercise 4.02: Detecting Shapes and Displaying Them on Black and White Images
      3. Exercise 4.03: Displaying Different Contours with Different Colors and Thicknesses
      4. Drawing a Bounding Box around a Contour
      5. Area of a Contour
      6. Difference between Contour Detection and Edge Detection
    3. Hierarchy
      1. Exercise 4.04: Detecting a Bolt and a Nut
      2. Exercise 4.05: Detecting a Basketball Net in an Image
    4. Contour Matching
      1. Exercise 4.06: Detecting Fruits in an Image
      2. Exercise 4.07: Identifying Bananas from the Image of Fruits
      3. Exercise 4.08: Detecting an Upright Banana from the Image of Fruits
      4. Activity 4.01: Identifying a Character on a Mirrored Document
    5. Summary
  7. 5. Face Processing in Image and Video
    1. Introduction
    2. Introduction to Haar Cascades
      1. Using Haar Cascades for Face Detection
      2. Exercise 5.01: Face Detection Using Haar Cascades
      3. Detecting Parts of the Face
      4. Exercise 5.02: Eye Detection Using Cascades
      5. Clubbing Cascades for Multiple Object Detection
      6. Activity 5.01: Eye Detection Using Multiple Cascades
      7. Activity 5.02: Smile Detection Using Haar Cascades
    3. GrabCut Technique
      1. Exercise 5.03: Human Body Segmentation Using GrabCut with Rectangular Mask
      2. Exercise 5.04: Human Body Segmentation Using Mask and ROI
      3. Activity 5.03: Skin Segmentation Using GrabCut
      4. Activity 5.04: Emoji Filter
    4. Summary
  8. 6. Object Tracking
    1. Introduction
      1. Naïve Tracker
      2. Exercise 6.01: Object Tracking Using Basic Image Processing
      3. Non-Deep Learning-Based Object Trackers
      4. Kalman Filter – Predict and Update
      5. Meanshift – Density Seeking Filter
      6. CAMshift – Continuously Adaptive Meanshift
      7. The OpenCV Object Tracking API
      8. Object Tracker Summary
      9. Exercise 6.02: Object Tracking Using the Median Flow and MIL Trackers
      10. Installing Dlib
      11. Object Tracking Using Dlib
      12. Exercise 6.03: Object Tracking Using Dlib
      13. Activity 6.01: Implementing Autofocus Using Object Tracking
    2. Summary
  9. 7. Object Detection and Face Recognition
    1. Introduction
    2. Face Recognition
      1. Face Recognition Using Eigenfaces
      2. Principal Component Analysis
      3. Eigenfaces
      4. Exercise 7.01: Facial Recognition Using Eigenfaces
      5. Limitations of the Eigenface Method
      6. Fisherface
      7. Exercise 7.02: Facial Recognition Using the Fisherface Method
      8. Local Binary Patterns Histograms
      9. Exercise 7.03: Facial Recognition Using the LBPH Method
    3. Object Detection
      1. Single Shot Detector
      2. MobileNet
      3. Exercise 7.04: Object Detection Using MobileNet SSD
      4. Object Detection Using the LBPH Method
      5. Exercise 7.05: Object Detection Using the LBPH Method
      6. Haar Cascades
      7. Exercise 7.06: Object Detection Using Haar-Based Features
      8. Activity 7.01: Object Detection in a Video Using MobileNet SSD
      9. Activity 7.02: Real-Time Facial Recognition Using LBPH
    4. Summary
  10. 8. OpenVINO with OpenCV
    1. Introduction
    2. Exploring the OpenVINO Toolkit
      1. Components of the OpenVINO Toolkit
      2. Installing OpenVINO for Ubuntu
      3. OpenVINO as a Backend in OpenCV
      4. The Need for Pre-Trained Models
      5. OpenVINO Model Zoo
      6. Exercise 8.01: Downloading the Pedestrian and Vehicle Detection Model
      7. Model Specifications
      8. Image Transforms Using OpenCV
      9. Exercise 8.02: Image Preprocessing Using OpenCV
    3. Model Conversion Using Model Optimizer
      1. Introduction to OpenVINO's Inference Engine
      2. Exercise 8.03: Vehicle and Pedestrian Detection
      3. Activity 8.01: Face Detection Using OpenVINO and OpenCV
    4. Summary
  11. Appendix
    1. 1. Basics of Image Processing
      1. Activity 1.01: Mirror Effect with a Twist
    2. 2. Common Operations When Working with Images
      1. Activity 2.01: Masking Using Binary Images
    3. 3. Working with Histograms
      1. Activity 3.01: Enhancing Images Using Histogram Equalization and CLAHE
      2. Activity 3.02: Image Enhancement in a User-Defined ROI
    4. 4. Working with contours
      1. Activity 4.01: Identifying a Character on a Mirrored Document
    5. 5. Face Processing in Image and Video
      1. Activity 5.01: Eye Detection Using Multiple Cascades
      2. Activity 5.02: Smile Detection Using Haar Cascades
      3. Activity 5.03: Skin Segmentation Using GrabCut
      4. Activity 5.04: Emoji Filter
    6. 6. Object Tracking
      1. Activity 6.01: Implementing Autofocus Using Object Tracking
    7. 7. Object Detection and Face Recognition
      1. Activity 7.01: Object Detection in a Video Using MobileNet SSD
      2. Activity 7.02: Real-Time Facial Recognition Using LBPH
    8. 8. OpenVINO with OpenCV
      1. Activity 8.01: Face Detection Using OpenVINO and OpenCV

Product information

  • Title: The Computer Vision Workshop
  • Author(s): Hafsa Asad, Vishwesh Ravi Shrimali, Nikhil Singh
  • Release date: July 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800201774