Book Image

Mastering OpenCV 4 - Third Edition

By : Roy Shilkrot, David Millán Escrivá
Book Image

Mastering OpenCV 4 - Third Edition

By: Roy Shilkrot, David Millán Escrivá

Overview of this book

Mastering OpenCV, now in its third edition, targets computer vision engineers taking their first steps toward mastering OpenCV. Keeping the mathematical formulations to a solid but bare minimum, the book delivers complete projects from ideation to running code, targeting current hot topics in computer vision such as face recognition, landmark detection and pose estimation, and number recognition with deep convolutional networks. You’ll learn from experienced OpenCV experts how to implement computer vision products and projects both in academia and industry in a comfortable package. You’ll get acquainted with API functionality and gain insights into design choices in a complete computer vision project. You’ll also go beyond the basics of computer vision to implement solutions for complex image processing projects. By the end of the book, you will have created various working prototypes with the help of projects in the book and be well versed with the new features of OpenCV4.
Table of Contents (12 chapters)

Accessing webcam streams

In the previous section, we learned how to read an image; now, we are going to learn how to read framed images from a webcam stream. To do this, we need the following HTML elements:

  • An alert box to show when OpenCV.js is loaded; because OpenCV.js is heavy and will take a few seconds to load on the client browser, then we are going to load it asynchronously and when it's loaded, we will start to load the other required code and user interfaces.
  • A video element to load the client video stream with the ID videoInput.
  • A Canvas element which shows the result of our algorithm.
  • A button to start processing video frames with the ID cv_start, which is initially hidden.

We are going to maintain the same alert box and canvas elements used in the previous sample and add two new elements, a button using the link and a video HTML element, as we can see in the...