Reader small image

You're reading from  Intel Edison Projects

Product typeBook
Published inMay 2017
PublisherPackt
ISBN-139781787288409
Edition1st Edition
Concepts
Right arrow
Author (1)
Avirup Basu
Avirup Basu
author image
Avirup Basu

http://www.avirupbasu.com/p/resume_9.html
Read more about Avirup Basu

Right arrow

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 page is locked
Previous PageNext Page
You have been reading a chapter from
Intel Edison Projects
Published in: May 2017Publisher: PacktISBN-13: 9781787288409

Author (1)

author image
Avirup Basu

http://www.avirupbasu.com/p/resume_9.html
Read more about Avirup Basu