Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Intel Edison Projects

You're reading from   Intel Edison Projects Build exciting IoT projects with Intel Edison

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781787288409
Length 264 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Avirup Basu Avirup Basu
Author Profile Icon Avirup Basu
Avirup Basu
Arrow right icon
View More author details
Toc

Table of Contents (7) Chapters Close

Preface 1. Setting up Intel Edison 2. Weather Station (IoT) FREE CHAPTER 3. Intel Edison and IoT (Home Automation) 4. Intel Edison and Security System 5. Autonomous Robotics with Intel Edison 6. Manual Robotics with Intel Edison

Intel Edison code

For the Intel Edison, let's find out what is actually possible. We don't have a display, so we can rely only on console messages and LED, perhaps, for visual signals. Next, we may need to optimize the code to run on the Intel Edison. But first let's edit the code discussed previously to include an LED and some kind of messages to the picture:

import cv2 
import numpy as np
import sys
import os

faceCascade = cv2.CascadeClassifier('C:/opencv/build/haarcascade_frontalface_default.xml')
video_capture = cv2.VideoCapture(0)
led = mraa.Gpio(13)
led.dir(mraa.DIR_OUT)
while (1):
led.write(0)
# Capture frame-by-frame
ret, frame = video_capture.read()

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray, 2, 4)
iflen(faces) > 0:
print("Detected")
led.write(1)
else:
print("You are clear...
lock icon The rest of the chapter is locked
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.
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 €18.99/month. Cancel anytime