Reader small image

You're reading from  OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition

Product typeBook
Published inMay 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789340723
Edition4th Edition
Languages
Tools
Right arrow
Authors (2):
David Millán Escrivá
David Millán Escrivá
author image
David Millán Escrivá

David Millán Escrivá was 8 years old when he wrote his first program on an 8086 PC in Basic, which enabled the 2D plotting of basic equations. In 2005, he finished his studies in IT with honors, through the Universitat Politécnica de Valencia, in human-computer interaction supported by computer vision with OpenCV (v0.96). He has worked with Blender, an open source, 3D software project, and on its first commercial movie, Plumiferos, as a computer graphics software developer. David has more than 10 years' experience in IT, with experience in computer vision, computer graphics, pattern recognition, and machine learning, working on different projects, and at different start-ups, and companies. He currently works as a researcher in computer vision.
Read more about David Millán Escrivá

Robert Laganiere
Robert Laganiere
author image
Robert Laganiere

Robert Laganiere is a professor at the School of Electrical Engineering and Computer Science of the University of Ottawa, Canada. He is also a faculty member of the VIVA research lab and is the co-author of several scientific publications and patents in content based video analysis, visual surveillance, driver-assistance, object detection, and tracking. Robert authored the OpenCV2 Computer Vision Application Programming Cookbook in 2011 and co-authored Object Oriented Software Development published by McGraw Hill in 2001. He co-founded Visual Cortek in 2006, an Ottawa-based video analytics start-up that was later acquired by iwatchlife.com in 2009. He is also a consultant in computer vision and has assumed the role of Chief Scientist in a number of start-up companies such as Cognivue Corp, iWatchlife, and Tempo Analytics. Robert has a Bachelor of Electrical Engineering degree from Ecole Polytechnique in Montreal (1987) and MSc and PhD degrees from INRS-Telecommunications, Montreal (1996). You can visit the author's website at laganiere.name.
Read more about Robert Laganiere

View More author details
Right arrow

OpenCV Advanced Features

Deep learning is a subfield of machine learning, based on traditional neural networks and convolutional neural networks. It's state-of-the-art pattern recognition. Deep learning is reaching the best accuracy in fields such as speech recognition, text recognition, and image classification. Actually, OpenCV adds the deep learning module as a basic module in its core algorithms and is making big efforts to increase its performance using CPUs and GPUs.

In this chapter of advanced features, we are going to cover how to enable Halide, a new language that OpenCV is using to improve the performance of deep learning inferences.

Finally, we are going to explore the new possibilities of using OpenCV in a web browser as a JavaScript library, which allows us to use computer vision in a web client without installing anything on the client computer.

In this chapter...

Face detection using deep learning

In this recipe, we are going to learn how to use a trained deep learning model for a face detection algorithm in OpenCV. To do this, we are going to download pre-trained face detection models and use OpenCV methods to import the model and also see how to convert an input image or frame into the required deep learning structure.

How to do it...

Using deep learning in OpenCV is very easy, and the only files that we require are the pre-trained models and know the basic configuration of it. We can download tested, pre-trained OpenCV models from https://github.com/opencv/open_model_zoo.

To create the face detector algorithm, follow these steps:

  1. Download and save the model of the face detector...

Object detection with YOLOv3

In this recipe, we are going to use the YOLOv3 DNN algorithm, which performs object detection. Object detection in an image is a common task in computer vision; with deep learning techniques, we can achieve highly accurate detections. YOLOv3 reaches a 60.6 mAP in the COCO dataset (80 classes and more than 300,000 images), which has a very good precision with 20 fps or 33 mAP with 220 fps.

How to do it...

In this recipe, we are going to use the same functions and classes to load the model, convert the images, and predict, but we are going to introduce one more important function non-maximum suppression and a few util functions to draw the predictions with their labels:

  1. Create...

Enabling Halide to improve efficiency

Halide is a new programming language written for high-performance image processing on new computers. Halide currently targets the following:

  • CPU architectures: X86, ARM, MIPS, Hexagon, and PowerPC
  • Operating systems: Linux, Windows, macOS, Android, iOS, and Qualcomm QuRT
  • GPU Compute APIs: CUDA, OpenCL, OpenGL, OpenGL Compute Shaders, Apple Metal, and Microsoft Direct X 12

In this recipe, we are going to show how to compile OpenCV with Halide and how to enable it in your DNN algorithms.

How to do it...

OpenCV.js introduction

This recipe introduces a new way to develop computer vision algorithms with OpenCV using JavaScript for the World Wide Web (WWW). Before OpenCV.js, developers that needed some computer vision tasks on the web had to develop them in C++ in servers or Java applets clients, which were not optimized, but with OpenCV.js, the new paradigm of client applications using web browsers has grown with unlimited of possibilities.

In this recipe, we are going to create a very simple case where we load an image into an img HTML tag, change the color image, and present it to a canvas element.

How to do it...

Before starting to use OpenCV.js, we need a web page as a user interface. To get a user interface, we are going...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
OpenCV 4 Computer Vision Application Programming Cookbook - Fourth Edition
Published in: May 2019Publisher: PacktISBN-13: 9781789340723
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
David Millán Escrivá

David Millán Escrivá was 8 years old when he wrote his first program on an 8086 PC in Basic, which enabled the 2D plotting of basic equations. In 2005, he finished his studies in IT with honors, through the Universitat Politécnica de Valencia, in human-computer interaction supported by computer vision with OpenCV (v0.96). He has worked with Blender, an open source, 3D software project, and on its first commercial movie, Plumiferos, as a computer graphics software developer. David has more than 10 years' experience in IT, with experience in computer vision, computer graphics, pattern recognition, and machine learning, working on different projects, and at different start-ups, and companies. He currently works as a researcher in computer vision.
Read more about David Millán Escrivá

author image
Robert Laganiere

Robert Laganiere is a professor at the School of Electrical Engineering and Computer Science of the University of Ottawa, Canada. He is also a faculty member of the VIVA research lab and is the co-author of several scientific publications and patents in content based video analysis, visual surveillance, driver-assistance, object detection, and tracking. Robert authored the OpenCV2 Computer Vision Application Programming Cookbook in 2011 and co-authored Object Oriented Software Development published by McGraw Hill in 2001. He co-founded Visual Cortek in 2006, an Ottawa-based video analytics start-up that was later acquired by iwatchlife.com in 2009. He is also a consultant in computer vision and has assumed the role of Chief Scientist in a number of start-up companies such as Cognivue Corp, iWatchlife, and Tempo Analytics. Robert has a Bachelor of Electrical Engineering degree from Ecole Polytechnique in Montreal (1987) and MSc and PhD degrees from INRS-Telecommunications, Montreal (1996). You can visit the author's website at laganiere.name.
Read more about Robert Laganiere