Discover how CUDA allows OpenCV to handle complex and rapidly growing image data processing in computer and machine vision by accessing the power of GPU
Author(s): Bhaumik Vaidya
Series: 1
Year: 0
Language: English
Pages: 506
Title Page......Page 2
Copyright and Credits......Page 3
Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA......Page 4
Packt Upsell......Page 5
Why subscribe?......Page 6
Packt.com......Page 7
Contributors......Page 8
About the author......Page 9
About the reviewer......Page 10
Packt is searching for authors like you......Page 11
Preface......Page 23
Who this book is for......Page 24
What this book covers......Page 25
To get the most out of this book......Page 27
Download the example code files......Page 28
Download the color images......Page 29
Code in Action......Page 30
Conventions used......Page 31
Get in touch......Page 32
Reviews......Page 33
Introducing CUDA and Getting Started with CUDA......Page 34
Technical requirements......Page 35
Introducing CUDA......Page 36
Parallel processing ......Page 37
Introducing GPU architecture and CUDA......Page 38
CUDA architecture......Page 40
CUDA applications......Page 42
CUDA development environment......Page 44
CUDA-supported GPU......Page 45
NVIDIA graphics card driver......Page 46
Standard C compiler......Page 47
CUDA development kit......Page 48
Installing the CUDA toolkit on all operating systems......Page 49
Windows......Page 50
Linux ......Page 52
Mac......Page 54
A basic program in CUDA C......Page 55
Steps for creating a CUDA C program on Windows ......Page 57
Steps for creating a CUDA C program on Ubuntu......Page 58
Summary......Page 59
Questions......Page 60
Parallel Programming using CUDA C......Page 61
Technical requirements......Page 62
CUDA program structure......Page 63
Two-variable addition program in CUDA C......Page 64
A kernel call......Page 67
Configuring kernel parameters......Page 69
CUDA API functions......Page 71
Passing parameters to CUDA functions......Page 73
Passing parameters by value......Page 74
Passing parameters by reference......Page 75
Executing threads on a device......Page 78
Accessing GPU device properties from CUDA programs......Page 80
General device properties......Page 81
Memory-related properties......Page 82
Thread-related properties......Page 83
Vector operations in CUDA ......Page 86
Two-vector addition program......Page 87
Comparing latency between the CPU and the GPU code ......Page 91
Elementwise squaring of vectors in CUDA......Page 92
Parallel communication patterns......Page 95
Map......Page 96
Gather......Page 97
Scatter......Page 98
Stencil......Page 99
Transpose ......Page 100
Summary......Page 101
Questions......Page 102
Threads, Synchronization, and Memory......Page 103
Technical requirements......Page 104
Threads......Page 105
Memory architecture......Page 109
Global memory......Page 111
Local memory and registers......Page 113
Cache memory......Page 114
Thread synchronization......Page 115
Shared memory......Page 116
Atomic operations......Page 119
Constant memory......Page 124
Texture memory......Page 127
Dot product and matrix multiplication example......Page 131
Dot product......Page 132
Matrix multiplication......Page 137
Summary......Page 142
Questions......Page 143
Advanced Concepts in CUDA......Page 144
Technical requirements......Page 145
Performance measurement of CUDA programs......Page 146
CUDA Events......Page 147
The Nvidia Visual Profiler......Page 150
Error handling in CUDA ......Page 154
Error handling from within the code......Page 155
Debugging tools......Page 157
Performance improvement of CUDA programs......Page 158
Using an optimum number of blocks and threads......Page 159
Maximizing arithmetic efficiency......Page 160
Using coalesced or strided memory access......Page 161
Avoiding thread divergence......Page 162
Using page-locked host memory......Page 163
CUDA streams......Page 164
Using multiple CUDA streams......Page 165
Acceleration of sorting algorithms using CUDA......Page 170
Enumeration or rank sort algorithms......Page 171
Image processing using CUDA......Page 174
Histogram calculation on the GPU using CUDA......Page 176
Summary......Page 182
Questions......Page 183
Getting Started with OpenCV with CUDA Support......Page 184
Technical requirements......Page 186
Introduction to image processing and computer vision......Page 187
Introduction to OpenCV......Page 189
Installation of OpenCV with CUDA support......Page 191
Installation of OpenCV on Windows......Page 192
Using pre-built binaries......Page 193
Building libraries from source......Page 194
Installation of OpenCV with CUDA support on Linux......Page 200
Working with images in OpenCV......Page 206
Image representation inside OpenCV......Page 207
Reading and displaying an image......Page 209
Reading and displaying a color image......Page 213
Creating images using OpenCV......Page 215
Drawing shapes on the blank image......Page 218
Drawing a line......Page 219
Drawing a rectangle......Page 220
Drawing a circle......Page 221
Drawing an ellipse......Page 222
Writing text on an image......Page 223
Saving an image to a file......Page 225
Working with videos in OpenCV......Page 226
Working with video stored on a computer......Page 227
Working with videos from a webcam......Page 230
Saving video to a disk......Page 232
Basic computer vision applications using the OpenCV CUDA module......Page 234
Introduction to the OpenCV CUDA module......Page 235
Arithmetic and logical operations on images......Page 236
Addition of two images......Page 237
Subtracting two images......Page 239
Image blending......Page 240
Image inversion......Page 241
Changing the color space of an image......Page 243
Image thresholding......Page 245
Performance comparison of OpenCV applications with and without CUDA support......Page 248
Summary......Page 252
Questions......Page 253
Basic Computer Vision Operations Using OpenCV and CUDA......Page 254
Technical requirements......Page 255
Accessing the individual pixel intensities of an image......Page 256
Histogram calculation and equalization in OpenCV......Page 258
Histogram equalization......Page 260
Grayscale images......Page 261
Color image......Page 263
Geometric transformation on images......Page 265
Image resizing......Page 266
Image translation and rotation......Page 268
Filtering operations on images......Page 270
Convolution operations on an image......Page 271
Low pass filtering on an image......Page 272
Averaging filters......Page 273
Gaussian filters......Page 275
Median filtering......Page 277
High-pass filtering on an image......Page 279
Sobel filters......Page 280
Scharr filters......Page 282
Laplacian filters......Page 284
Morphological operations on images......Page 286
Summary......Page 290
Questions......Page 291
Object Detection and Tracking Using OpenCV and CUDA......Page 292
Technical requirements......Page 294
Introduction to object detection and tracking......Page 295
Applications of object detection and tracking......Page 296
Challenges in object detection......Page 297
Object detection and tracking based on color......Page 298
Blue object detection and tracking......Page 299
Object detection and tracking based on shape......Page 302
Canny edge detection......Page 303
Straight line detection using Hough transform......Page 305
Circle detection ......Page 309
Key-point detectors and descriptors......Page 311
Features from Accelerated Segment Test (FAST) feature detector......Page 312
Oriented FAST and Rotated BRIEF (ORB) feature detection......Page 315
Speeded up robust feature detection and matching......Page 317
Object detection using Haar cascades......Page 322
Face detection using Haar cascades......Page 323
From video......Page 325
Eye detection using Haar cascades......Page 327
Object tracking using background subtraction......Page 329
Mixture of Gaussian (MoG) method......Page 330
GMG for background subtraction......Page 333
Summary......Page 337
Questions......Page 338
Introduction to the Jetson TX1 Development Board and Installing OpenCV on Jetson TX1......Page 339
Technical requirements......Page 340
Introduction to Jetson TX1......Page 341
Important features of the Jetson TX1......Page 344
Applications of Jetson TX1......Page 345
Installation of JetPack on Jetson TX1......Page 346
Basic requirements for installation......Page 347
Steps for installation......Page 348
Summary......Page 357
Questions......Page 358
Deploying Computer Vision Applications on Jetson TX1......Page 359
Technical requirements......Page 360
Device properties of Jetson TX1 GPU......Page 361
Basic CUDA program on Jetson TX1......Page 363
Image processing on Jetson TX1 ......Page 366
Compiling OpenCV with CUDA support (if necessary)......Page 367
Reading and displaying images......Page 369
Image addition......Page 371
Image thresholding......Page 373
Image filtering on Jetson TX1......Page 376
Interfacing cameras with Jetson TX1......Page 379
Reading and displaying video from onboard camera......Page 380
Advanced applications on Jetson TX1......Page 383
Face detection using Haar cascades......Page 384
Eye detection using Haar cascades......Page 387
Background subtraction using Mixture of Gaussian (MoG)......Page 389
Computer vision using Python and OpenCV on Jetson TX1......Page 393
Summary......Page 395
Questions......Page 396
Getting Started with PyCUDA......Page 397
Technical requirements......Page 398
Introduction to Python programming language......Page 399
Introduction to the PyCUDA module......Page 400
Installing PyCUDA on Windows......Page 401
Steps to check PyCUDA installation......Page 407
Installing PyCUDA on Ubuntu......Page 408
Steps to check the PyCUDA installation......Page 412
Summary......Page 413
Questions......Page 414
Working with PyCUDA......Page 415
Technical requirements......Page 416
Writing the first program in PyCUDA ......Page 417
A kernel call......Page 420
Accessing GPU device properties from PyCUDA program......Page 421
Thread and block execution in PyCUDA......Page 424
Basic programming concepts in PyCUDA ......Page 426
Adding two numbers in PyCUDA ......Page 427
Simplifying the addition program using driver class......Page 430
Measuring performance of PyCUDA programs using CUDA events......Page 432
CUDA events......Page 433
Measuring performance of PyCUDA using large array addition ......Page 435
Complex programs in PyCUDA......Page 438
Element-wise squaring of a matrix in PyCUDA......Page 439
Simple kernel invocation with multidimensional threads......Page 440
Using inout with the kernel invocation......Page 443
Using gpuarray class......Page 445
Dot product using GPU array......Page 447
Matrix multiplication......Page 449
Advanced kernel functions in PyCUDA......Page 452
Element-wise kernel in PyCUDA......Page 453
Reduction kernel ......Page 455
Scan kernel ......Page 457
Summary......Page 459
Questions......Page 460
Basic Computer Vision Applications Using PyCUDA......Page 461
Technical requirements......Page 462
Histogram calculation in PyCUDA......Page 463
Using atomic operations......Page 464
Using shared memory......Page 467
Basic computer vision operations using PyCUDA......Page 470
Color space conversion in PyCUDA......Page 471
BGR to gray conversion on an image......Page 472
BGR to gray conversion on a webcam video......Page 474
Image addition in PyCUDA......Page 476
Image inversion in PyCUDA using gpuarray......Page 478
Summary......Page 480
Questions......Page 481
Assessments......Page 482
Chapter 1......Page 483
Chapter 2......Page 484
Chapter 3......Page 487
Chapter 4......Page 489
Chapter 5......Page 491
Chapter 6......Page 494
Chapter 7......Page 495
Chapter 8......Page 497
Chapter 9......Page 498
Chapter 10......Page 499
Chapter 11......Page 500
Chapter 12......Page 502
Other Books You May Enjoy......Page 504
Leave a review - let other readers know what you think......Page 506