Skip to Content
Hands-On Edge Analytics with Azure IoT
book

Hands-On Edge Analytics with Azure IoT

by Colin Dow
May 2020
Intermediate to advanced
262 pages
6h 48m
English
Packt Publishing
Content preview from Hands-On Edge Analytics with Azure IoT

Explaining the code

The magic in our program is performed by the OpenCV library. We start out our code by importing it via cv2. We also import the LED class from gpiozero to control the LED that we will use for the alarm:

import cv2from gpiozero import LED

We define our image file as face.png. As there is no directory reference, be sure to have the picture located in the same directory you are running the code from.

To perform image recognition, OpenCV requires a cascade file. This is basically an XML file used to describe what a particular object looks like to the computer. In this case, it is a face in the frontal position, hence the name of the file is haarcascade_frontalface_default.xml

We then create an alarm object by assigning it ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Azure IoT Edge Computing: Extending the Cloud to the Intelligent Edge

Beginning Azure IoT Edge Computing: Extending the Cloud to the Intelligent Edge

David Jensen

Publisher Resources

ISBN: 9781838829902Supplemental Content