Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
55 views

Face Detection Security System Using Pi Node Red I

This document describes the steps to create a face detection security system using a Raspberry Pi, Node-RED, IBM Watson, Twilio, and email services. An old smartphone is configured as an IP camera to take photos when motion is detected by a PIR sensor. Node-RED is used to program the flow, capturing photos and sending them to IBM Watson for visual recognition. If a face is detected, Twilio sends an SMS and the photo is attached to an email. The system provides notification when someone visits a home while the owner is away.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Face Detection Security System Using Pi Node Red I

This document describes the steps to create a face detection security system using a Raspberry Pi, Node-RED, IBM Watson, Twilio, and email services. An old smartphone is configured as an IP camera to take photos when motion is detected by a PIR sensor. Node-RED is used to program the flow, capturing photos and sending them to IBM Watson for visual recognition. If a face is detected, Twilio sends an SMS and the photo is attached to an email. The system provides notification when someone visits a home while the owner is away.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

technology workshop craft home food play outside costumes

Face detection Security System using Pi, Node-red, IBM-Watson, Twilio, Email
service
by TryxCorp on October 29, 2016

Table of Contents

Face detection Security System using Pi, Node-red, IBM-Watson, Twilio, Email service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Face detection Security System using Pi, Node-red, IBM-Watson, Twilio, Email service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Step 1: Setting up your PIR-Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 3: Step 2: Setting up an old Smartphone as IP-Camera And capturing a snapshot from that camera in Node-Red . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 4: Step 3: A two way file node is used to read the image in the local directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 5: Step 4: Setting up a twilio account and Bluemix Account and using them in Node-Red . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 6: Step 5: Using visual recognition node under IBM-Watson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 7: Step 6: Switch nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 8: The Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Author:TryxCorp Jayanth
TryxCorp is a small group of DIY enthusiasts. We have a passion to create innovative products and designs. We make sure that each of our instructables are
different from the already existing similar ones. We actually thought of building a start up company in it's name but ended up making all our ideas open
source. Members of Tryxcorp : Shrenik, Jayanth, Shrisha, Nikhil, Karun, Achyut, Khalid, Bharath

Intro: Face detection Security System using Pi, Node-red, IBM-Watson, Twilio, Email service
Disclaimer: You may get scared by looking at so many new terms that you will come across in this Instructable if you are a total beginner to Raspberry Pi. ;-) But trust
me, there is literally NO CODING employed here and also this instructable is actually very simple and easy to implement. Hence there is no reason for you to get
scared.

Ever wanted to know who had arrived at your door step when you were away from home?

Ever wanted to know when they had tried to visit your home?

Wouldn't it be good to receive some kind of notification when someone arrives at your doorstep and you are away from home and offline at the same time. This tutorial
helps you set up a system where you can get a SMS to your mobile, and an email containing the photo of a person who has visited your house as an
attachment file , by using an old smartphone as IP-Camera, Raspberry-Pi and a PIR-Sensor, Node-Red visual programming tool, Watson's Visual recognition
tool ,Twilio and Email service.

An old smartphone is used as an IP-Camera which allows us take the snapshot at any moment when it is connected to a local network with the help of a Raspberry-Pi.
Decision of when to take the snapshot is determined with the help of a PIR-Sensor

This tutorial uses NODE -RED visual programming tool which takes the help of IBM-Watson by making use of its services through nodes, IBM-Watson's visual
recognition service which detects a face and then execute other commands based on the response obtained from Watson , Twilio SMS - Service allows you to send
sms to your number or multiple numbers containing message that someone is at the doorstep, and an email service which allows us to send an email containing the
face of a Person who had visited your home. As you can see that since we are using a visual programming tool, almost no code is being written by us!

This tutorial shows how you to create a service in Bluemix and setup a Raspberry Pi which will be connected to your Bluemix's IoT Platform service.

Step 1: Prerequisites
Materials Required:

1) Raspberry Pi - Any model

2) PIR-Sensor

3) Old smartphone or any Camera which can be connected to a network

4) Power bank or a constant power supply for Raspberry Pi

5) Wifi Router (or the smartphone itself can act as a wifi router if there is an option)

Assumptions:

1) Have basic knowledge in Raspberry Pi

2) Node-Red installed on Pi (you can visit this Tutorial on how to install Node-Red on Pi and connect it to Watson)

3) In raspberry Pi, the "node-red" command is executed in the directory ~/.node-red

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
(use the command "cd ~/.node-red" in terminal)

Keywords:

1) Nodes and Node-Red: Nodes are drag and drop icons in the Visual program editor Node-Red

2) IP-Camera: These are the cameras which can be operated by any other device connected to the same network

3) IBM-Watson-Bluemix: IBM has an AI Bot called Watson which can be used over cloud for various purposes

Bluemix is a platform to create Watson's application and services

4) Twilio: This is a cloud based SMS service app which can be used to send free text messages by running programs

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 2: Step 1: Setting up your PIR-Sensor
PIR-Sensor is used for motion detection. It helps to capture snapshots from the IP-Camera only when Activity is detected in front of door.

Steps:

1)The VCC pin and the GROUND pin of the PIR sensor is connected to the Pi's 5V pin and GROUND pin respectively.

2) The Digital OUTPUT pin of the PIR-Sensor is given as input to the Raspberry Pi's GPIO pin 11. Any GPIO pi can be used for this purpose

3)The DIGITAL status of the OUTPIN pin of PIR-Sensor can be seen in Node-Red page.

It sends a digital signal when a motion is detected. This is taken as an input to the Raspberry Pi. The GPIO input node in NODE-RED is used to read the input signal.

As soon as a signal is detected, The flow in NODE-RED programs halts for 5 seconds because of the DELAY node

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 3: Step 2: Setting up an old Smartphone as IP-Camera And capturing a snapshot from that camera in Node-Red
I have used my old smartphone to act as an IP-Camera, which allows me to control it using Raspberry Pi, both of which are connected to the same local network(Home
Router).

The App which I used is called " IP Webcam" which is downloaded from playstore. Similar apps can also be found for other platforms too like iOS, Windows. In the end,
all we need to do is to be able to get an image from the camera at any instant in the form of a download link.

I have used the curl command for the raspberry pi in the form of a exec-node in Node-Red.

This allows me to save the snapshot in the form a jpg file in the local directory(~/.node-red) of raspberry Pi.

The file is saved as an image file with the name "photo.jpg"

For a Video tutorial on how to turn your smartphone into IP-Camera , visit this tutorial

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 4: Step 3: A two way file node is used to read the image in the local directory
1) A two way file node in the Node-Red page is used to read the image in the local directory which is named as "photo.jpg".

2) The data is read in Buffer mode and is checked for valid image before passing to the next node.

3) If msg.payload[0] == Null, The imaged obtained with the help of curl command is invalid file.(This happens when the IP-Camera is not running in the Local network
and the download file is a ile)

If msg.payload[0] is not null, The image obtained from curl command is a valid image file and can be used.

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 5: Step 4: Setting up a twilio account and Bluemix Account and using them in Node-Red
We are going to use Twilio service and IBM-Bluemix's Visual recognition service.

1) Twilio is a cloud platform used for SMS, Voice, and Messaging apps on an API.

Based on personal experience, Twilio's features are very easy to operate in Node-Red, instead of Running script file for sending sms. Its messages can be sent almost
instantaneously when Twilio's service is called using node.
The Twilio node is configured in the Node-Red page itself by entering the required credentials in the node's settings menu under local credentials.To send a SMS to a
number, the topic parameter of the msg object must be set to the number, e.g. +4416358000xx and the payload parameter is the actual message that is to be sent. In a
simple test, you would use an inject node to create the msg topic and payload, this would feed directly into the Twilio node to send the SMS. How this is used would be
up to your own imagination and requirements.

2) Create a Bluemix account and create Visual Recognition service app in bluemix and note the the credentials obtained.Under Visual Recognition Node, The
credentials which you had noted down earlier when you created the Visual-Recognition service app, is insterted under the edit menu of the node.

You can find many other servicesunder IBM-Watson tab in Node-Red. All you have to do is to create an app in your Bluemix account and note down the credentials and
use it wherever required.

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 6: Step 5: Using visual recognition node under IBM-Watson
1) The visual recognition node from IBM-Watson takes image url or buffer of an image as input.

2) I gave the buffer of "photo.jpg" which was present in the local directory

3) Input is given through msg.payload.

4) The output is seen in msg.result

msg.result displays all the details which is obtained by IBM-Watson's analysis.

the result contains all the objects which are classified by Watson.

5) Based on the result, we shall can know if a person is detected in the image, or if something else is detected in the image.

6) From these two cases, we can send different messages for different conditions using the help of switch node.

Please Note: Here, by Visual recognition service , a person is being detected and not the face.

If you want Face to be detected by Visual recognition service, then you must choose the Classifier object under visual recognition node's edit menu as Faces and use
switch case node appropriately. In this case, if you want a face to be detected in particular, msg.result.images[0].faces==(not null)

Step 7: Step 6: Switch nodes


The switch nodes are used to send sms and emails appropriately.

1) Is the Camera working? -->> Send Message 1

2) Person classified in the image?--->> Send message 2

3) Person not classified in the image?--->>>send message 3

Function nodes are used to write additional code to the blocks.

1) They are used to create subject name and attachment file with time stamp as its name to the msg JSON file..

Templates are used to make your own json files.

1) They are used to add messages to the msg.payload whicha re then sent to Twilio

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/
Step 8: The Conclusion
I have used several function nodes and file nodes as needed for the program to flow.

Feel free to explore the Node-Red. It has lot of other nodes too , all of which are very easy to understand.

Use the above screenshot for reference and try to create your own nodes. Ping me if you have any doubts regarding this instructables.

In case you want to add some extra features, like turn on led light during night time when PIR sensor detects motion, one could simply use the Rpi.GPIO nodes available
as output nodes, and then capture the snapshot and save it to a file.

The IBM-Watson also supports speech to text service, So you can send your messages in the form of voice with the help of speakers when a Guest has visited your
house.You can learn how to convert text to speech with the help of this link Tutorial for Connecting a Raspberry Pi to IBM Watson, Bluemix and Node-RED

If you want to check my Node-red page nodes, Import the clipboard from the node-red webpage.

There is going to be a working video of this Instructable very soon.

Comment if you have anything to say at all regarding this instructables.

Hope you enjoyed reading this Instructable :)

Thank you!!

File Downloads

node-red clipboard.txt (5 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'node-red clipboard.txt']

Related Instructables

Motion A Smart Water Connect A smart JPEG Raspberry Pi - GSM IFTTT


Detection Alarm Sensor that Raspberry Pi As camera for SMS Garage Button by
System by sends text a Device to IBM home security Door Butler by brandonhawkes
nivenenna messages by Watson IoT by by Stephen LEE AkiraFist
paulware amprasanna

Advertisements

Comments

http://www.instructables.com/id/Face-Detection-Security-System-Using-Pi-Node-red-I/

You might also like