Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA

Book description

Discover how CUDA computing platform allows OpenCV to handle rapidly growing computer and machine vision complex image data processing by accessing the power of GPU

About This Book
  • Practical examples to leverage the GPU processing power with OpenCV and CUDA
  • Maximise the performance of algorithms on embedded hardware platforms
  • Work with C++ and Python libraries for GPU acceleration
Who This Book Is For

This book is a go-to guide for developers working with OpenCV and now want to learn how to process more complex image data by taking advantage of GPU processing. A thorough understanding of computer vision concepts and programming languages like C++ or Python is expected.

What You Will Learn
  • How to access GPU device properties and capabilities from CUDA programs
  • know the acceleration of searching and sorting algorithms using CUDA
  • Detect shapes like lines or circles from images using OpenCV and CUDA
  • Object tracking and detection with algorithms using OpenCV and CUDA
  • Process videos using different video analysis techniques on jetson TX1
  • Know how to access GPU device properties from PyCUDA program
  • Get to know how Kernal execution works
In Detail

Computer vision is revolutionizing wide range of industries and OpenCV is the most widely chosen tool for computer vision with the ability to work in multiple programming languages. Now a days in Computer vision there is a need to process large images in real time which is difficult to handle for OpenCV on its own. This is where CUDA comes into the picture, allowing OpenCV to leverage powerful NVDIA GPUs. This book provides a detail overview on integrating OpenCV with CUDA for practical applications.

It starts with explaining programming of GPU with CUDA which is essential for computer vision developers who have never worked with GPU. Then it explains OpenCV acceleration with GPU and CUDA by taking some practical examples. This book covers deployment of OpenCV applications on NVIDIA Jetson Tx1 which is very popular for computer vision and deep learning applications. The last part of the book covers the concept of PyCUDA which can be used by Computer vision developers who are using OpenCV with Python. PyCUDA is a python library which leverages power of CUDA and GPU for accelerations. This book provides complete guide for developers using OpenCV in C++ or Python in accelerating their computer vision applications by taking hands-on approach.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA
  3. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Code in Action
      4. Conventions used
    4. Get in touch
      1. Reviews
  6. Introducing CUDA and Getting Started with CUDA
    1. Technical requirements
    2. Introducing CUDA
      1. Parallel processing
      2. Introducing GPU architecture and CUDA
      3. CUDA architecture
    3. CUDA applications
    4. CUDA development environment
      1. CUDA-supported GPU
      2. NVIDIA graphics card driver
      3. Standard C compiler
      4. CUDA development kit
    5. Installing the CUDA toolkit on all operating systems
      1. Windows
      2. Linux
      3. Mac
    6. A basic program in CUDA C
      1. Steps for creating a CUDA C program on Windows
      2. Steps for creating a CUDA C program on Ubuntu
    7. Summary
    8. Questions
  7. Parallel Programming using CUDA C
    1. Technical requirements
    2. CUDA program structure
      1. Two-variable addition program in CUDA C
      2. A kernel call
      3. Configuring kernel parameters
      4. CUDA API functions
      5. Passing parameters to CUDA functions
        1. Passing parameters by value
        2. Passing parameters by reference
    3. Executing threads on a device
    4. Accessing GPU device properties from CUDA programs
      1. General device properties
      2. Memory-related properties
      3. Thread-related properties
    5. Vector operations in CUDA
      1. Two-vector addition program
      2. Comparing latency between the CPU and the GPU code
      3. Elementwise squaring of vectors in CUDA
    6. Parallel communication patterns
      1. Map
      2. Gather
      3. Scatter
      4. Stencil
      5. Transpose
    7. Summary
    8. Questions
  8. Threads, Synchronization, and Memory
    1. Technical requirements
    2. Threads
    3. Memory architecture
      1. Global memory
      2. Local memory and registers
      3. Cache memory
    4. Thread synchronization
      1. Shared memory
      2. Atomic operations
    5. Constant memory
    6. Texture memory
    7. Dot product and matrix multiplication example
      1. Dot product
      2. Matrix multiplication
    8. Summary
    9. Questions
  9. Advanced Concepts in CUDA
    1. Technical requirements
    2. Performance measurement of CUDA programs
      1. CUDA Events
      2. The Nvidia Visual Profiler
    3. Error handling in CUDA
      1. Error handling from within the code
      2. Debugging tools
    4. Performance improvement of CUDA programs
      1. Using an optimum number of blocks and threads
      2. Maximizing arithmetic efficiency
      3. Using coalesced or strided memory access
      4. Avoiding thread divergence
      5. Using page-locked host memory
    5. CUDA streams
      1. Using multiple CUDA streams
    6. Acceleration of sorting algorithms using CUDA
      1. Enumeration or rank sort algorithms
    7. Image processing using CUDA
      1. Histogram calculation on the GPU using CUDA
    8. Summary
    9. Questions
  10. Getting Started with OpenCV with CUDA Support
    1. Technical requirements
    2. Introduction to image processing and computer vision
    3. Introduction to OpenCV
    4. Installation of OpenCV with CUDA support
      1. Installation of OpenCV on Windows
        1. Using pre-built binaries
        2. Building libraries from source
      2. Installation of OpenCV with CUDA support on Linux
    5. Working with images in OpenCV
      1. Image representation inside OpenCV
      2. Reading and displaying an image
        1. Reading and displaying a color image
      3. Creating images using OpenCV
        1. Drawing shapes on the blank image
          1. Drawing a line
          2. Drawing a rectangle
          3. Drawing a circle
          4. Drawing an ellipse
          5. Writing text on an image
      4. Saving an image to a file
    6. Working with videos in OpenCV
      1. Working with video stored on a computer
      2. Working with videos from a webcam
      3. Saving video to a disk
    7. Basic computer vision applications using the OpenCV CUDA module
      1. Introduction to the OpenCV CUDA module
      2. Arithmetic and logical operations on images
        1. Addition of two images
        2. Subtracting two images
        3. Image blending
        4. Image inversion
      3. Changing the color space of an image
      4. Image thresholding
    8. Performance comparison of OpenCV applications with and without CUDA support
    9. Summary
    10. Questions
  11. Basic Computer Vision Operations Using OpenCV and CUDA
    1. Technical requirements
    2. Accessing the individual pixel intensities of an image
    3. Histogram calculation and equalization in OpenCV
      1. Histogram equalization
        1. Grayscale images
        2. Color image
    4. Geometric transformation on images
      1. Image resizing
      2. Image translation and rotation
    5. Filtering operations on images
      1. Convolution operations on an image
      2. Low pass filtering on an image
        1. Averaging filters
        2. Gaussian filters
        3. Median filtering
      3. High-pass filtering on an image
        1. Sobel filters
        2. Scharr filters
        3. Laplacian filters
    6. Morphological operations on images
    7. Summary
    8. Questions
  12. Object Detection and Tracking Using OpenCV and CUDA
    1. Technical requirements
    2. Introduction to object detection and tracking
      1. Applications of object detection and tracking
      2. Challenges in object detection
    3. Object detection and tracking based on color
      1. Blue object detection and tracking
    4. Object detection and tracking based on shape
      1. Canny edge detection
      2. Straight line detection using Hough transform
      3. Circle detection
    5. Key-point detectors and descriptors
      1. Features from Accelerated Segment Test (FAST) feature detector
      2. Oriented FAST and Rotated BRIEF (ORB) feature detection
      3. Speeded up robust feature detection and matching
    6. Object detection using Haar cascades
      1. Face detection using Haar cascades
        1. From video
      2. Eye detection using Haar cascades
    7. Object tracking using background subtraction
      1. Mixture of Gaussian (MoG) method
      2. GMG for background subtraction
    8. Summary
    9. Questions
  13. Introduction to the Jetson TX1 Development Board and Installing OpenCV on Jetson TX1
    1. Technical requirements
    2. Introduction to Jetson TX1
      1. Important features of the Jetson TX1
      2. Applications of Jetson TX1
    3. Installation of JetPack on Jetson TX1
      1. Basic requirements for installation
      2. Steps for installation
    4. Summary
    5. Questions
  14. Deploying Computer Vision Applications on Jetson TX1
    1. Technical requirements
    2. Device properties of Jetson TX1 GPU
    3. Basic CUDA program on Jetson TX1
    4. Image processing on Jetson TX1
      1. Compiling OpenCV with CUDA support (if necessary)
      2. Reading and displaying images
      3. Image addition
      4. Image thresholding
      5. Image filtering on Jetson TX1
    5. Interfacing cameras with Jetson TX1
      1. Reading and displaying video from onboard camera
    6. Advanced applications on Jetson TX1
      1. Face detection using Haar cascades
      2. Eye detection using Haar cascades
      3. Background subtraction using Mixture of Gaussian (MoG)
    7. Computer vision using Python and OpenCV on Jetson TX1
    8. Summary
    9. Questions
  15. Getting Started with PyCUDA
    1. Technical requirements
    2. Introduction to Python programming language
    3. Introduction to the PyCUDA module
    4. Installing PyCUDA on Windows
      1. Steps to check PyCUDA installation
    5. Installing PyCUDA on Ubuntu
      1. Steps to check the PyCUDA installation
    6. Summary
    7. Questions
  16. Working with PyCUDA
    1. Technical requirements
    2. Writing the first program in PyCUDA
      1. A kernel call
    3. Accessing GPU device properties from PyCUDA program
    4. Thread and block execution in PyCUDA
    5. Basic programming concepts in PyCUDA
      1. Adding two numbers in PyCUDA
      2. Simplifying the addition program using driver class
    6. Measuring performance of PyCUDA programs using CUDA events
      1. CUDA events
      2. Measuring performance of PyCUDA using large array addition
    7. Complex programs in PyCUDA
      1. Element-wise squaring of a matrix in PyCUDA
        1. Simple kernel invocation with multidimensional threads
        2. Using inout with the kernel invocation
        3. Using gpuarray class
      2. Dot product using GPU array
      3. Matrix multiplication
    8. Advanced kernel functions in PyCUDA
      1. Element-wise kernel in PyCUDA
      2. Reduction kernel
      3. Scan kernel
    9. Summary
    10. Questions
  17. Basic Computer Vision Applications Using PyCUDA
    1. Technical requirements
    2. Histogram calculation in PyCUDA
      1. Using atomic operations
      2. Using shared memory
    3. Basic computer vision operations using PyCUDA
      1. Color space conversion in PyCUDA
        1. BGR to gray conversion on an image
        2. BGR to gray conversion on a webcam video
      2. Image addition in PyCUDA
      3. Image inversion in PyCUDA using gpuarray
    4. Summary
    5. Questions
  18. Assessments
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA
  • Author(s): Bhaumik Vaidya
  • Release date: September 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781789348293