SlideShare une entreprise Scribd logo
1  sur  65
BUILDING A
SMART
SECURITY
CAMERA WITH
PIZERO, JAVA
AND AWS
@markawest
Who Am I?
• IT Consultant at Bouvet.
• Hacker and Maker.
• Java, JavaScript, AI, Cloud & IoT.
• Active member of javaBin - the
Norwegian JUG.
@markawest
Talk Outline
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image
Analysis with
AWS
Evaluation
and Tips
Node.js vs
Java Lambda
Functions
@markawest
Motivation and Requirements
Input from Stakeholder
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image Analysis
with AWS
Evaluation and
Tips
Node.js vs Java
@markawest
Initial Motivation
@markawest
Project Requirements
Functional
• Monitor activity in the
garden.
• Send warning when activity
detected.
• Live video stream.
Non-functional
• In place as soon as possible.
• Low cost.
• Portable.
@markawest
Functional Design
1. Activity
in garden
2. Camera
detects
movement
3. Camera sends
alert email with
snapshot
@markawest
Building a Motion Activated
Camera
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image Analysis
with AWS
Evaluation and
Tips
Node.js vs Java
Lambda
Functions
@markawest
Pi Zero W Essentials Kit: NOK 285
Camera Module: NOK 244
Camera Adapter: NOK 41
ZeroView: NOK 71
Total Cost: NOK 641
Hardware Shopping List
@markawest
Assembled Camera
Rear View Front View
@markawest
Implementing the Functional Design
1. Activity
in garden
2. Camera
detects
movement
3. Camera sends
alert email with
snapshot
@markawest
Motion
(https://motion-project.github.io)
• Open source motion detection software.
• Excellent performance on the Raspberry Pi Zero.
• Built-in Web Server for streaming video.
• Detected activity or ‘motion’ triggers events.
• Works out of the box. No need for additional programming.
@markawest
Motion
Streaming
Demo
@markawest
Example
Alert Email
1 2
1
@markawest
How the Motion Software works
1 2 3 4
@markawest
1 2 3
How the Motion Software works
1 2 3 4
1 2 3
@markawest
1 2 3
How the Motion Software works
1 2 3 4
1 2 3
@markawest
1 2 3
Alarm Snapshots from Web Camera
@markawest
Project Requirements : Evaluation
Functional
• Monitor activity in the
garden.
• Send warning when activity
detected.
• Live video stream.
Non-functional
• In place as soon as possible.
• Low cost.
• Portable.
@markawest
False Alarms from Web Camera
cat
cloud
@markawest
The Motion Software
focuses on the amount of
changed pixels, and not the
cause of the changed
pixels!
@markawest
Adding Smart Image Analysis
with AWS
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image Analysis
with AWS
Evaluation and
Tips
Node.js vs Java
Lambda
Functions
@markawest
Improving Alarm Accuracy with
Smart Image Analysis
person
@markawest
cat
Project Requirements Reloaded
Functional
• Monitor activity in our
garden.
• Send warning when activity
detected.
• Live video stream.
Non-functional
• In place as soon as possible.
• Low cost.
• Portable.
@markawest
Project Requirements Reloaded
Functional
• Monitor activity in our
garden.
• Send warning when human
activity detected.
• Live video stream.
Non-functional
• In place as soon as possible.
• Low cost.
• Portable.
@markawest
Finding an Image Analysis Solution
OpenCV
• Use Face Detection to find out if
a human was in the snapshot.
• Problem: What if the subject
was facing away from the
camera, or wearing a mask?
TensorFlow
• Train and use a Neural Network
to find humans in the snapshot.
• Problem: Potentially a fun
project, but would take more
time than I had available.
@markawest
AWS Rekognition
• Part of Amazon Web Services suite of Cloud based services.
• Image Analysis as a Service, offering a range of API’s.
• Built upon Deep Neural Networks.
• Officially launched in November 2016.
• Alternatives: Google Vision, MicroSoft Computer Vision, Clarafai.
@markawest
AWS Rekognition Demo
@markawest
Adding AWS to the Web Camera
Amazon Web Services (AWS)
Send warning
email (if snapshot
contains a person)
Snapshot analysed
via AWS
Rekognition
@markawest
Camera pushes
snapshot to AWS
Email alert sent
(with snapshot)
AWS IAM
AWS
Rekognition
AWS Simple
Email Service
AWS S3
(storage)
Amazon Web Service Flow
Overview
AWS Step Function
(workflow)
Upload
Trigger
1
2
4
5
6
calls
3
uses
uses
@markawest
AWS IAM
AWS
Rekognition
AWS Simple
Email Service
AWS S3
(storage)
AWS Lambda Functions
Code Building Blocks (aka Microservices)
AWS Step Function
(workflow)
Upload
Trigger calls
uses
uses
@markawest
AWS Lambda Functions
• Code units based on Java, C#, Python or Node.js
• Serverless, no infrastructure to manage.
• High availability out of the box.
• Pay as you go model based on total invocations and duration -
with a generous free tier.
• Native AWS SDK gives easy access to other AWS services.
@markawest
AWS Lambda Demo
@markawest
AWS IAM
AWS S3
(storage)
AWS Step Functions
Orchestration of Lambda Functions
AWS Step Function
(workflow)
Upload
Trigger calls
AWS
Rekognition
AWS Simple
Email Service
uses
uses
@markawest
AWS Step Functions
• Coordinate and orchestrate Lambda Functions into Workflows or
State Machines.
• Launched in December 2016.
• Defined via JSON files, displayed as visual workflows.
• Provide the same benefits as AWS Lambda (High Availability,
Serverless, Scalable, “Pay as you go” pricing model).
@markawest
Step Function for Image Processing
Error
Handler
(sends
Error
Email via
AWS
SES)
Sends snapshot to AWS Rekognition
Evaluate AWS Rekognition response
Send Alert Email?
Send Alert Email
via AWS SES
Archive image in AWS S3
1
2
3
4
5
6 1
2
3
4
5
6
@markawest
Smart Camera
(plus AWS Step Function)
Demo
@markawest
Evaluation and Lessons
Learned
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image Analysis
with AWS
Evaluation and
Tips
Node.js vs Java
Lambda
Functions
@markawest
Project Requirements : Evaluation
Functional
• Monitor activity in the
garden.
• Send warning when human
activity detected.
• Live video stream.
Non-functional
• In place as soon as possible.
• Low cost.
• Portable.
@markawest
Benefits of Using AWS
• Very easy to get started with, due to Free Tier, automated
infrastructure and good documentation.
• Large ecosystem with a broad range of services.
• Serverless - so hot right now!
@markawest
Drawbacks of Using AWS
• It’s not free.
• So many services!
• Step Functions need a graphical editor.
• Potential for vendor lock-in.
@markawest
AWS Rekognition : Positives
• Consistent results.
• Good results from 'partial’ images.
• Handles poor quality images (motion
blur, poor lighting).
• No more false alarms from the camera!
@markawest
AWS Rekognition : Negatives
• Black box.
• Unable to provide feedback.
• Struggles with ‘noisy’ pictures.
• Results are only as good as the pictures
you upload.
@markawest
Activity Timeline
Improving AWS Rekognition Results
@markawest
Activity
Event
Start
1 Activity
Event
Stop
2 3 4 5
Activity Timeline
Improving AWS Rekognition Results
@markawest
Activity
Event
Start
1 Activity
Event
Stop
2 3 4 5
Most
Pixels
Changed
Activity Timeline
Improving AWS Rekognition Results
@markawest
Activity
Event
Start
1 Activity
Event
Stop
2 3 4 5
Most
Central
Activity
Activity Timeline
Improving AWS Rekognition Results
@markawest
Activity
Event
Start
1 Activity
Event
Stop
2 3 4 5
Upload all snapshots
Improving AWS Rekognition Hit Rate
Upload One Snapshot
when activity detected
• Lower cost, due to less calls
to the AWS stack.
• Potentially lower hit rate.
Upload Many Snapshots
when activity detected
• Higher cost due to
increased calls to the AWS
stack.
• Potentially higher hit rate.
@markawest
AWS Monthly Cost : August 2017
@markawest
Rekognition:
$3.09
SES: $0.01S3: $0.49
Step
Functions:
$1.12
VAT: $1.17
(Based on 8093 images processed)
Lambda: $0.00
“Fun project, but has it
caught any real criminals?”
@markawest
@markawest
Node.js vs Java
Motivation
and
Requirements
Building a
Motion
Activated
Camera
Adding Smart
Image Analysis
with AWS
Evaluation and
Tips
Node.js vs Java
Lambda
Functions
@markawest
Java 8 vs. Node.js 6.10
1. Artefact Sizes
2. Memory Requirements
3. Performance and Cost
@markawest
AWS Lambda Functions
@markawest
Lambda Function Purpose AWS Service Calls
rekognition-image-
assessment
Uses AWS Rekognition to generate a
list of labels describing each
uploaded picture.
AWS Rekognition
rekognition-evaluate-labels
Evaluates labels to find out if an
alarm email should be sent.
-
ses-send-notification
Sends an alarm email via AWS SES
when the smart security camera
detects a person.
AWS SES
s3-archive-image
Moves the processed image to the
correct archive location in S3.
AWS S3
Artefact Sizes
3 Reasons for the difference:
1. Java is generally more
verbose.
2. Unused JAR’s in Java
Deployments.
3. AWS SDK is natively
available to Node.js
Lambda Functions.
@markawest
Lambda Function Java Node
rekognition-image-
assessment
7.9
MB
813
bytes
rekognition-evaluate-
labels
7.6
MB
677
bytes
ses-send-notification
8.7
MB
4.8
MB
s3-archive-image
7.6
MB
943
bytes
Memory Requirements
Memory
Allocated
AWS Free
Seconds Per
Month
AWS Price
Per Second
128 MB 3 200 000 $0.00000208
192 MB 2 133 333 $0.00000313
256 MB 1 600 000 $0.00000417
1536 MB 266 667 $0.00002501
@markawest
• Node.js 6.10 happy with
128 MB memory.
• Java 8 requires a minimum
of 192 MB, and preferably
256 MB to avoid
OutOfMemoryException
errors.
Testing Cost & Performance : Method
• Simulate 1500 alerts (not false alarms).
• Triggered in batches of 30, with a 60 second pause.
• Memory set to 256 MB for both Node.js and Java.
• Prior to testing, Lambda Functions “rested” for 90 minutes.
• Ran tests 5 times to ensure consistency of results.
@markawest
Results from AWS CloudWatch
• User defined graphical
dashboards based on log data.
• Example shows execution
duration data for one of the
Java AWS Lambda Functions.
• Note the Cold Starts.
@markawest
Test Results
@markawest
Lambda Function
Average
Duration Java
Average
Duration Node.js
rekognition-image-assessment 2250 ms 1720 ms
rekognition-evaluate-labels 6.57 ms 1.61 ms
ses-send-notification 3040 ms 996 ms
s3-archive-image 1050 ms 364 ms
Extrapolated Duration Costs
• 256 MB memory.
• $0.00000417 per second.
• 1 600 000 free seconds.
AWS
Lambda
Function
Type
1 000 000
Alerts
5 000 000
Alerts
10 000 000
Alerts
Java $23.39 $143.66 $293.99
Node.js $7.63 $64.84 $136.36
@markawest
Extrapolated Duration Costs
256 MB
Memory
$0.00000417
per second
1 600 000
free seconds
AWS
Lambda
Function
Type
1 000 000
Alerts
5 000 000
Alerts
10 000 000
Alerts
Java $23.39 $143.66 $293.99
Node.js $7.63 $64.84 $136.36
@markawest
Why was Java slower on AWS Lambda?
• Cold Starts (5-10 times longer on Java).
• Lack of JVM tuning options on AWS.
• Different underlying implementations.
• Use Case for Project Jigsaw?
@markawest
Is there a place for Java on
AWS Lambda?
• Of course there is!
• Evaluate your use case and potential costs first.
• Select languages based on overall value.
• Try different memory settings to reduce costs.
• Remember the Free Tier!
@markawest
Would you like to know more?
markwest1972/
smart-security-
camera
bouvet.no/bouvet-
deler
@markawest
slideshare.net/
markawest
Slides Blog Code
FOR
LISTENING!
@markawest
Kraków, 17-19 May 2017

Contenu connexe

Tendances

AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAmazon Web Services
 
AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)Doguhan Uluca
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)Amazon Web Services
 
To Serverless And Beyond!
To Serverless And Beyond!To Serverless And Beyond!
To Serverless And Beyond!SheenBrisals
 
AWS re:Invent 2016: Open-Source Resources (DCS201)
AWS re:Invent 2016: Open-Source Resources (DCS201)AWS re:Invent 2016: Open-Source Resources (DCS201)
AWS re:Invent 2016: Open-Source Resources (DCS201)Amazon Web Services
 
Serverless Workflows on AWS - A Journey from SWF to Step Functions
Serverless Workflows on AWS - A Journey from SWF to Step FunctionsServerless Workflows on AWS - A Journey from SWF to Step Functions
Serverless Workflows on AWS - A Journey from SWF to Step FunctionsForrest Brazeal
 
Serverless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversServerless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversAmazon Web Services
 
Distributed Serverless Stack Tracing and Monitoring
Distributed Serverless Stack Tracing and MonitoringDistributed Serverless Stack Tracing and Monitoring
Distributed Serverless Stack Tracing and MonitoringAmazon Web Services
 
Sloppy Little Serverless Stories
Sloppy Little Serverless StoriesSloppy Little Serverless Stories
Sloppy Little Serverless StoriesSheenBrisals
 
Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201Amazon Web Services
 
Workshop : Wild Rydes Takes Off - The Dawn of a New Unicorn
Workshop : Wild Rydes Takes Off - The Dawn of a New UnicornWorkshop : Wild Rydes Takes Off - The Dawn of a New Unicorn
Workshop : Wild Rydes Takes Off - The Dawn of a New UnicornAmazon Web Services
 
(SPOT302) Availability: The New Kind of Innovator’s Dilemma
(SPOT302) Availability: The New Kind of Innovator’s Dilemma(SPOT302) Availability: The New Kind of Innovator’s Dilemma
(SPOT302) Availability: The New Kind of Innovator’s DilemmaAmazon Web Services
 
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig Dickson
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig DicksonAWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig Dickson
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig DicksonAmazon Web Services Korea
 
Enterprise Serverless Adoption. An Experience Report
Enterprise Serverless Adoption. An Experience ReportEnterprise Serverless Adoption. An Experience Report
Enterprise Serverless Adoption. An Experience ReportSheenBrisals
 
Building serverless app_using_aws_lambda_b4usolution
Building serverless app_using_aws_lambda_b4usolutionBuilding serverless app_using_aws_lambda_b4usolution
Building serverless app_using_aws_lambda_b4usolutionHoa Le
 
Using AWS Lambda for Infrastructure Automation and Beyond
Using AWS Lambda for Infrastructure Automation and BeyondUsing AWS Lambda for Infrastructure Automation and Beyond
Using AWS Lambda for Infrastructure Automation and BeyondSoftServe
 
How LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With ServerlessHow LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With ServerlessSheenBrisals
 
Building a WorkFlow using AWS Step Functions with Skycatch
Building a WorkFlow using AWS Step Functions with SkycatchBuilding a WorkFlow using AWS Step Functions with Skycatch
Building a WorkFlow using AWS Step Functions with SkycatchAmazon Web Services
 

Tendances (20)

AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the Cloud
 
AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
 
To Serverless And Beyond!
To Serverless And Beyond!To Serverless And Beyond!
To Serverless And Beyond!
 
AWS re:Invent 2016: Open-Source Resources (DCS201)
AWS re:Invent 2016: Open-Source Resources (DCS201)AWS re:Invent 2016: Open-Source Resources (DCS201)
AWS re:Invent 2016: Open-Source Resources (DCS201)
 
Serverless Culture
Serverless CultureServerless Culture
Serverless Culture
 
Serverless
ServerlessServerless
Serverless
 
Serverless Workflows on AWS - A Journey from SWF to Step Functions
Serverless Workflows on AWS - A Journey from SWF to Step FunctionsServerless Workflows on AWS - A Journey from SWF to Step Functions
Serverless Workflows on AWS - A Journey from SWF to Step Functions
 
Serverless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversServerless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about servers
 
Distributed Serverless Stack Tracing and Monitoring
Distributed Serverless Stack Tracing and MonitoringDistributed Serverless Stack Tracing and Monitoring
Distributed Serverless Stack Tracing and Monitoring
 
Sloppy Little Serverless Stories
Sloppy Little Serverless StoriesSloppy Little Serverless Stories
Sloppy Little Serverless Stories
 
Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201
 
Workshop : Wild Rydes Takes Off - The Dawn of a New Unicorn
Workshop : Wild Rydes Takes Off - The Dawn of a New UnicornWorkshop : Wild Rydes Takes Off - The Dawn of a New Unicorn
Workshop : Wild Rydes Takes Off - The Dawn of a New Unicorn
 
(SPOT302) Availability: The New Kind of Innovator’s Dilemma
(SPOT302) Availability: The New Kind of Innovator’s Dilemma(SPOT302) Availability: The New Kind of Innovator’s Dilemma
(SPOT302) Availability: The New Kind of Innovator’s Dilemma
 
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig Dickson
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig DicksonAWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig Dickson
AWS Innovate: Smaller IS Better – Exploiting Microservices on AWS, Craig Dickson
 
Enterprise Serverless Adoption. An Experience Report
Enterprise Serverless Adoption. An Experience ReportEnterprise Serverless Adoption. An Experience Report
Enterprise Serverless Adoption. An Experience Report
 
Building serverless app_using_aws_lambda_b4usolution
Building serverless app_using_aws_lambda_b4usolutionBuilding serverless app_using_aws_lambda_b4usolution
Building serverless app_using_aws_lambda_b4usolution
 
Using AWS Lambda for Infrastructure Automation and Beyond
Using AWS Lambda for Infrastructure Automation and BeyondUsing AWS Lambda for Infrastructure Automation and Beyond
Using AWS Lambda for Infrastructure Automation and Beyond
 
How LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With ServerlessHow LEGO.com Accelerates With Serverless
How LEGO.com Accelerates With Serverless
 
Building a WorkFlow using AWS Step Functions with Skycatch
Building a WorkFlow using AWS Step Functions with SkycatchBuilding a WorkFlow using AWS Step Functions with Skycatch
Building a WorkFlow using AWS Step Functions with Skycatch
 

Similaire à JavaZone 2017 : Building a smart security camera with raspberry pi zero, java and aws

IoT Meetup Oslo - AI on Edge Devices
IoT Meetup Oslo - AI on Edge DevicesIoT Meetup Oslo - AI on Edge Devices
IoT Meetup Oslo - AI on Edge DevicesMark West
 
IoT Tech Day Smart Camera slides. Utrecht, April 2017.
IoT Tech Day Smart Camera slides.  Utrecht, April 2017.IoT Tech Day Smart Camera slides.  Utrecht, April 2017.
IoT Tech Day Smart Camera slides. Utrecht, April 2017.Mark West
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
Getting Started with Serverless Apps
Getting Started with Serverless AppsGetting Started with Serverless Apps
Getting Started with Serverless AppsAmazon Web Services
 
AWS September Webinar Series - Build Cross-Platform Mobile Apps with AWS and...
AWS September Webinar Series -  Build Cross-Platform Mobile Apps with AWS and...AWS September Webinar Series -  Build Cross-Platform Mobile Apps with AWS and...
AWS September Webinar Series - Build Cross-Platform Mobile Apps with AWS and...Amazon Web Services
 
Surviving Serverless Testing: The ultimate Guide
Surviving Serverless Testing: The ultimate GuideSurviving Serverless Testing: The ultimate Guide
Surviving Serverless Testing: The ultimate GuideOPEN KNOWLEDGE GmbH
 
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAmazon Web Services
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
AWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayAWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayEitan Sela
 
Rails in the Cloud
Rails in the CloudRails in the Cloud
Rails in the Cloudiwarshak
 
AWS Lambda - Event Driven Event-driven Code in the Cloud
AWS Lambda - Event Driven Event-driven Code in the CloudAWS Lambda - Event Driven Event-driven Code in the Cloud
AWS Lambda - Event Driven Event-driven Code in the CloudAmazon Web Services
 
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...Amazon Web Services
 
AWS Lambda: Event-Driven Code in the Cloud
AWS Lambda: Event-Driven Code in the CloudAWS Lambda: Event-Driven Code in the Cloud
AWS Lambda: Event-Driven Code in the CloudAmazon Web Services
 
NEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeNEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeAmazon Web Services
 
Yow Conference Dec 2013 Netflix Workshop Slides with Notes
Yow Conference Dec 2013 Netflix Workshop Slides with NotesYow Conference Dec 2013 Netflix Workshop Slides with Notes
Yow Conference Dec 2013 Netflix Workshop Slides with NotesAdrian Cockcroft
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesAmazon Web Services
 
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...Amazon Web Services
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSAmazon Web Services
 

Similaire à JavaZone 2017 : Building a smart security camera with raspberry pi zero, java and aws (20)

IoT Meetup Oslo - AI on Edge Devices
IoT Meetup Oslo - AI on Edge DevicesIoT Meetup Oslo - AI on Edge Devices
IoT Meetup Oslo - AI on Edge Devices
 
IoT Tech Day Smart Camera slides. Utrecht, April 2017.
IoT Tech Day Smart Camera slides.  Utrecht, April 2017.IoT Tech Day Smart Camera slides.  Utrecht, April 2017.
IoT Tech Day Smart Camera slides. Utrecht, April 2017.
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with Serverless Apps
Getting Started with Serverless AppsGetting Started with Serverless Apps
Getting Started with Serverless Apps
 
AWS September Webinar Series - Build Cross-Platform Mobile Apps with AWS and...
AWS September Webinar Series -  Build Cross-Platform Mobile Apps with AWS and...AWS September Webinar Series -  Build Cross-Platform Mobile Apps with AWS and...
AWS September Webinar Series - Build Cross-Platform Mobile Apps with AWS and...
 
Surviving Serverless Testing: The ultimate Guide
Surviving Serverless Testing: The ultimate GuideSurviving Serverless Testing: The ultimate Guide
Surviving Serverless Testing: The ultimate Guide
 
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
 
AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
AWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayAWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-Ray
 
Rails in the Cloud
Rails in the CloudRails in the Cloud
Rails in the Cloud
 
AWS Lambda - Event Driven Event-driven Code in the Cloud
AWS Lambda - Event Driven Event-driven Code in the CloudAWS Lambda - Event Driven Event-driven Code in the Cloud
AWS Lambda - Event Driven Event-driven Code in the Cloud
 
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...
Connect and Interconnect – The Mesh of Event-Driven Compute and Marvelous Vir...
 
AWS Lambda: Event-Driven Code in the Cloud
AWS Lambda: Event-Driven Code in the CloudAWS Lambda: Event-Driven Code in the Cloud
AWS Lambda: Event-Driven Code in the Cloud
 
NEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeNEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the Edge
 
AWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless Cloud
 
Yow Conference Dec 2013 Netflix Workshop Slides with Notes
Yow Conference Dec 2013 Netflix Workshop Slides with NotesYow Conference Dec 2013 Netflix Workshop Slides with Notes
Yow Conference Dec 2013 Netflix Workshop Slides with Notes
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
 
Serverless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWSServerless Geospatial Mobile Apps with AWS
Serverless Geospatial Mobile Apps with AWS
 

Plus de Mark West

A Practical-ish Introduction to Data Science
A Practical-ish Introduction to Data ScienceA Practical-ish Introduction to Data Science
A Practical-ish Introduction to Data ScienceMark West
 
Explaining the new Java release and licensing models
Explaining the new Java release and licensing modelsExplaining the new Java release and licensing models
Explaining the new Java release and licensing modelsMark West
 
GeeCon Prague 2018 - A Practical-ish Introduction to Data Science
GeeCon Prague 2018 - A Practical-ish Introduction to Data ScienceGeeCon Prague 2018 - A Practical-ish Introduction to Data Science
GeeCon Prague 2018 - A Practical-ish Introduction to Data ScienceMark West
 
JavaZone 2018 - A Practical(ish) Introduction to Data Science
JavaZone 2018 - A Practical(ish) Introduction to Data ScienceJavaZone 2018 - A Practical(ish) Introduction to Data Science
JavaZone 2018 - A Practical(ish) Introduction to Data ScienceMark West
 
NDC Oslo : A Practical Introduction to Data Science
NDC Oslo : A Practical Introduction to Data ScienceNDC Oslo : A Practical Introduction to Data Science
NDC Oslo : A Practical Introduction to Data ScienceMark West
 
JavaZone 2016 : MQTT and CoAP for the Java Developer
JavaZone 2016 : MQTT and CoAP for the Java DeveloperJavaZone 2016 : MQTT and CoAP for the Java Developer
JavaZone 2016 : MQTT and CoAP for the Java DeveloperMark West
 
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-Five
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-FiveJavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-Five
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-FiveMark West
 
Coding Mojo : Node.js Meetup
Coding Mojo : Node.js MeetupCoding Mojo : Node.js Meetup
Coding Mojo : Node.js MeetupMark West
 
IoT Tech Day Coding Mojo slides. Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides. Utrecht, April 2016Mark West
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...Mark West
 

Plus de Mark West (10)

A Practical-ish Introduction to Data Science
A Practical-ish Introduction to Data ScienceA Practical-ish Introduction to Data Science
A Practical-ish Introduction to Data Science
 
Explaining the new Java release and licensing models
Explaining the new Java release and licensing modelsExplaining the new Java release and licensing models
Explaining the new Java release and licensing models
 
GeeCon Prague 2018 - A Practical-ish Introduction to Data Science
GeeCon Prague 2018 - A Practical-ish Introduction to Data ScienceGeeCon Prague 2018 - A Practical-ish Introduction to Data Science
GeeCon Prague 2018 - A Practical-ish Introduction to Data Science
 
JavaZone 2018 - A Practical(ish) Introduction to Data Science
JavaZone 2018 - A Practical(ish) Introduction to Data ScienceJavaZone 2018 - A Practical(ish) Introduction to Data Science
JavaZone 2018 - A Practical(ish) Introduction to Data Science
 
NDC Oslo : A Practical Introduction to Data Science
NDC Oslo : A Practical Introduction to Data ScienceNDC Oslo : A Practical Introduction to Data Science
NDC Oslo : A Practical Introduction to Data Science
 
JavaZone 2016 : MQTT and CoAP for the Java Developer
JavaZone 2016 : MQTT and CoAP for the Java DeveloperJavaZone 2016 : MQTT and CoAP for the Java Developer
JavaZone 2016 : MQTT and CoAP for the Java Developer
 
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-Five
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-FiveJavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-Five
JavaZone 2015 : NodeBots - JavaScript Powered Robots with Johnny-Five
 
Coding Mojo : Node.js Meetup
Coding Mojo : Node.js MeetupCoding Mojo : Node.js Meetup
Coding Mojo : Node.js Meetup
 
IoT Tech Day Coding Mojo slides. Utrecht, April 2016
IoT Tech Day Coding Mojo slides.  Utrecht, April 2016IoT Tech Day Coding Mojo slides.  Utrecht, April 2016
IoT Tech Day Coding Mojo slides. Utrecht, April 2016
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
 

Dernier

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Dernier (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

JavaZone 2017 : Building a smart security camera with raspberry pi zero, java and aws

  • 2. Who Am I? • IT Consultant at Bouvet. • Hacker and Maker. • Java, JavaScript, AI, Cloud & IoT. • Active member of javaBin - the Norwegian JUG. @markawest
  • 3. Talk Outline Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java Lambda Functions @markawest
  • 4. Motivation and Requirements Input from Stakeholder Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java @markawest
  • 6. Project Requirements Functional • Monitor activity in the garden. • Send warning when activity detected. • Live video stream. Non-functional • In place as soon as possible. • Low cost. • Portable. @markawest
  • 7. Functional Design 1. Activity in garden 2. Camera detects movement 3. Camera sends alert email with snapshot @markawest
  • 8. Building a Motion Activated Camera Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java Lambda Functions @markawest
  • 9. Pi Zero W Essentials Kit: NOK 285 Camera Module: NOK 244 Camera Adapter: NOK 41 ZeroView: NOK 71 Total Cost: NOK 641 Hardware Shopping List @markawest
  • 10. Assembled Camera Rear View Front View @markawest
  • 11. Implementing the Functional Design 1. Activity in garden 2. Camera detects movement 3. Camera sends alert email with snapshot @markawest
  • 12. Motion (https://motion-project.github.io) • Open source motion detection software. • Excellent performance on the Raspberry Pi Zero. • Built-in Web Server for streaming video. • Detected activity or ‘motion’ triggers events. • Works out of the box. No need for additional programming. @markawest
  • 15. How the Motion Software works 1 2 3 4 @markawest 1 2 3
  • 16. How the Motion Software works 1 2 3 4 1 2 3 @markawest 1 2 3
  • 17. How the Motion Software works 1 2 3 4 1 2 3 @markawest 1 2 3
  • 18. Alarm Snapshots from Web Camera @markawest
  • 19. Project Requirements : Evaluation Functional • Monitor activity in the garden. • Send warning when activity detected. • Live video stream. Non-functional • In place as soon as possible. • Low cost. • Portable. @markawest
  • 20. False Alarms from Web Camera cat cloud @markawest
  • 21. The Motion Software focuses on the amount of changed pixels, and not the cause of the changed pixels! @markawest
  • 22. Adding Smart Image Analysis with AWS Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java Lambda Functions @markawest
  • 23. Improving Alarm Accuracy with Smart Image Analysis person @markawest cat
  • 24. Project Requirements Reloaded Functional • Monitor activity in our garden. • Send warning when activity detected. • Live video stream. Non-functional • In place as soon as possible. • Low cost. • Portable. @markawest
  • 25. Project Requirements Reloaded Functional • Monitor activity in our garden. • Send warning when human activity detected. • Live video stream. Non-functional • In place as soon as possible. • Low cost. • Portable. @markawest
  • 26. Finding an Image Analysis Solution OpenCV • Use Face Detection to find out if a human was in the snapshot. • Problem: What if the subject was facing away from the camera, or wearing a mask? TensorFlow • Train and use a Neural Network to find humans in the snapshot. • Problem: Potentially a fun project, but would take more time than I had available. @markawest
  • 27. AWS Rekognition • Part of Amazon Web Services suite of Cloud based services. • Image Analysis as a Service, offering a range of API’s. • Built upon Deep Neural Networks. • Officially launched in November 2016. • Alternatives: Google Vision, MicroSoft Computer Vision, Clarafai. @markawest
  • 29. Adding AWS to the Web Camera Amazon Web Services (AWS) Send warning email (if snapshot contains a person) Snapshot analysed via AWS Rekognition @markawest Camera pushes snapshot to AWS Email alert sent (with snapshot)
  • 30. AWS IAM AWS Rekognition AWS Simple Email Service AWS S3 (storage) Amazon Web Service Flow Overview AWS Step Function (workflow) Upload Trigger 1 2 4 5 6 calls 3 uses uses @markawest
  • 31. AWS IAM AWS Rekognition AWS Simple Email Service AWS S3 (storage) AWS Lambda Functions Code Building Blocks (aka Microservices) AWS Step Function (workflow) Upload Trigger calls uses uses @markawest
  • 32. AWS Lambda Functions • Code units based on Java, C#, Python or Node.js • Serverless, no infrastructure to manage. • High availability out of the box. • Pay as you go model based on total invocations and duration - with a generous free tier. • Native AWS SDK gives easy access to other AWS services. @markawest
  • 34. AWS IAM AWS S3 (storage) AWS Step Functions Orchestration of Lambda Functions AWS Step Function (workflow) Upload Trigger calls AWS Rekognition AWS Simple Email Service uses uses @markawest
  • 35. AWS Step Functions • Coordinate and orchestrate Lambda Functions into Workflows or State Machines. • Launched in December 2016. • Defined via JSON files, displayed as visual workflows. • Provide the same benefits as AWS Lambda (High Availability, Serverless, Scalable, “Pay as you go” pricing model). @markawest
  • 36. Step Function for Image Processing Error Handler (sends Error Email via AWS SES) Sends snapshot to AWS Rekognition Evaluate AWS Rekognition response Send Alert Email? Send Alert Email via AWS SES Archive image in AWS S3 1 2 3 4 5 6 1 2 3 4 5 6 @markawest
  • 37. Smart Camera (plus AWS Step Function) Demo @markawest
  • 38. Evaluation and Lessons Learned Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java Lambda Functions @markawest
  • 39. Project Requirements : Evaluation Functional • Monitor activity in the garden. • Send warning when human activity detected. • Live video stream. Non-functional • In place as soon as possible. • Low cost. • Portable. @markawest
  • 40. Benefits of Using AWS • Very easy to get started with, due to Free Tier, automated infrastructure and good documentation. • Large ecosystem with a broad range of services. • Serverless - so hot right now! @markawest
  • 41. Drawbacks of Using AWS • It’s not free. • So many services! • Step Functions need a graphical editor. • Potential for vendor lock-in. @markawest
  • 42. AWS Rekognition : Positives • Consistent results. • Good results from 'partial’ images. • Handles poor quality images (motion blur, poor lighting). • No more false alarms from the camera! @markawest
  • 43. AWS Rekognition : Negatives • Black box. • Unable to provide feedback. • Struggles with ‘noisy’ pictures. • Results are only as good as the pictures you upload. @markawest
  • 44. Activity Timeline Improving AWS Rekognition Results @markawest Activity Event Start 1 Activity Event Stop 2 3 4 5
  • 45. Activity Timeline Improving AWS Rekognition Results @markawest Activity Event Start 1 Activity Event Stop 2 3 4 5 Most Pixels Changed
  • 46. Activity Timeline Improving AWS Rekognition Results @markawest Activity Event Start 1 Activity Event Stop 2 3 4 5 Most Central Activity
  • 47. Activity Timeline Improving AWS Rekognition Results @markawest Activity Event Start 1 Activity Event Stop 2 3 4 5 Upload all snapshots
  • 48. Improving AWS Rekognition Hit Rate Upload One Snapshot when activity detected • Lower cost, due to less calls to the AWS stack. • Potentially lower hit rate. Upload Many Snapshots when activity detected • Higher cost due to increased calls to the AWS stack. • Potentially higher hit rate. @markawest
  • 49. AWS Monthly Cost : August 2017 @markawest Rekognition: $3.09 SES: $0.01S3: $0.49 Step Functions: $1.12 VAT: $1.17 (Based on 8093 images processed) Lambda: $0.00
  • 50. “Fun project, but has it caught any real criminals?” @markawest
  • 52. Node.js vs Java Motivation and Requirements Building a Motion Activated Camera Adding Smart Image Analysis with AWS Evaluation and Tips Node.js vs Java Lambda Functions @markawest
  • 53. Java 8 vs. Node.js 6.10 1. Artefact Sizes 2. Memory Requirements 3. Performance and Cost @markawest
  • 54. AWS Lambda Functions @markawest Lambda Function Purpose AWS Service Calls rekognition-image- assessment Uses AWS Rekognition to generate a list of labels describing each uploaded picture. AWS Rekognition rekognition-evaluate-labels Evaluates labels to find out if an alarm email should be sent. - ses-send-notification Sends an alarm email via AWS SES when the smart security camera detects a person. AWS SES s3-archive-image Moves the processed image to the correct archive location in S3. AWS S3
  • 55. Artefact Sizes 3 Reasons for the difference: 1. Java is generally more verbose. 2. Unused JAR’s in Java Deployments. 3. AWS SDK is natively available to Node.js Lambda Functions. @markawest Lambda Function Java Node rekognition-image- assessment 7.9 MB 813 bytes rekognition-evaluate- labels 7.6 MB 677 bytes ses-send-notification 8.7 MB 4.8 MB s3-archive-image 7.6 MB 943 bytes
  • 56. Memory Requirements Memory Allocated AWS Free Seconds Per Month AWS Price Per Second 128 MB 3 200 000 $0.00000208 192 MB 2 133 333 $0.00000313 256 MB 1 600 000 $0.00000417 1536 MB 266 667 $0.00002501 @markawest • Node.js 6.10 happy with 128 MB memory. • Java 8 requires a minimum of 192 MB, and preferably 256 MB to avoid OutOfMemoryException errors.
  • 57. Testing Cost & Performance : Method • Simulate 1500 alerts (not false alarms). • Triggered in batches of 30, with a 60 second pause. • Memory set to 256 MB for both Node.js and Java. • Prior to testing, Lambda Functions “rested” for 90 minutes. • Ran tests 5 times to ensure consistency of results. @markawest
  • 58. Results from AWS CloudWatch • User defined graphical dashboards based on log data. • Example shows execution duration data for one of the Java AWS Lambda Functions. • Note the Cold Starts. @markawest
  • 59. Test Results @markawest Lambda Function Average Duration Java Average Duration Node.js rekognition-image-assessment 2250 ms 1720 ms rekognition-evaluate-labels 6.57 ms 1.61 ms ses-send-notification 3040 ms 996 ms s3-archive-image 1050 ms 364 ms
  • 60. Extrapolated Duration Costs • 256 MB memory. • $0.00000417 per second. • 1 600 000 free seconds. AWS Lambda Function Type 1 000 000 Alerts 5 000 000 Alerts 10 000 000 Alerts Java $23.39 $143.66 $293.99 Node.js $7.63 $64.84 $136.36 @markawest
  • 61. Extrapolated Duration Costs 256 MB Memory $0.00000417 per second 1 600 000 free seconds AWS Lambda Function Type 1 000 000 Alerts 5 000 000 Alerts 10 000 000 Alerts Java $23.39 $143.66 $293.99 Node.js $7.63 $64.84 $136.36 @markawest
  • 62. Why was Java slower on AWS Lambda? • Cold Starts (5-10 times longer on Java). • Lack of JVM tuning options on AWS. • Different underlying implementations. • Use Case for Project Jigsaw? @markawest
  • 63. Is there a place for Java on AWS Lambda? • Of course there is! • Evaluate your use case and potential costs first. • Select languages based on overall value. • Try different memory settings to reduce costs. • Remember the Free Tier! @markawest
  • 64. Would you like to know more? markwest1972/ smart-security- camera bouvet.no/bouvet- deler @markawest slideshare.net/ markawest Slides Blog Code

Notes de l'éditeur

  1. But before I go any further I’d like to tell you a couple of things about me. In my day job I am a manager in Bouvet’s Oslo offices, where I work with a range of technologies based upon Java and JavaScript. My current focus is upon AI, Cloud and the Internet of Things. When I’m not at work I can often be found working on a range of hobby projects – often using the Raspberry Pi and Arduino platforms. In addition I am also involved in the organisation of the JavaZone conference, where I primarily work with the program committee. I’m on twitter under the handle @markawest, so feel free to contact me if there is anything you’d like to talk about!
  2. Ok, so lets look at the outline of todays talk. We’ll start in a second with a run through of the motivation for building this camera, along with the requirements. These should always be clear and defined for any project, whether it is a multi million kroner project for NAV, or a hobby project undertaken by an englishman living in Oslo. Then we’ll look at the first version of the camera, evaluate how it worked and discuss it’s weaknesses. The second version of the camera is where we introduce Amazon Web Services to the mix and will take up the majority of the presentation time. Finally I’ll evaluate the project and talk about what I learned.
  3. Ok, so lets get started by looking at why I did this project!
  4. The motivation for creating my camera was simple enough. A large amount of break-ins had recently taken plan in the area where I live. The thieves targeted houses with secluded gardens, as the chance of being spotted by passers by was lower. My garden is not visible from the road, making it a prime target for the thieves.
  5. When undertaking any project you need to identify the stakeholders, or those who will be affected by the project outcome. These stakeholders will have their expectations of the project, and your requirements should always take the stakeholders expectations into account. For this project my wife was my primary stakeholder, so the requirements reflected her wishes. (Go through requirements)
  6. Once I’d gathered the requirements I realized that I needed to implement the above, in a cost effective and speedy manner.
  7. Ok, so lets get started by looking at why I did this project!
  8. We’ll begin by looking at the hardware I used for creating the Camera and how much this costs. The Pi Zero is a cut down version of the Raspberry Pi. They cost about 50kr, but you’ll also need to buy an SD card, power supply and HDMI and USB adapters. Therefore I recommend a starter kit such as the one sold by the Pi Hut. This costs 300 kr, and gives you all you need to get started with the Pi Zero. In addition to the Pi Zero board I needed a camera. I choose the Raspberry Pi Camera module, at around 250 kr. To fit this to the Pi Zero I also had to buy a Pi Zero Camera adapter, which cost an additional 50 kr. The camera I chose was the Pi NoIR, which work better in low conditions. To truly provide night vision it requires an IR light source, which I didn’t buy for this project. Finally I needed a mount for the Camera. I choose the ZeroView at 80 kr. The total cost for all equipment (if bought new) would be therefore approximately 680kr. If this seems a lot of money, remember that you can easily reuse the components for other projects at a later point!
  9. We’ll begin by looking at the hardware I used for creating the Camera and how much this costs. The Pi Zero is a cut down version of the Raspberry Pi. They cost about 50kr, but you’ll also need to buy an SD card, power supply and HDMI and USB adapters. Therefore I recommend a starter kit such as the one sold by the Pi Hut. This costs 300 kr, and gives you all you need to get started with the Pi Zero. In addition to the Pi Zero board I needed a camera. I choose the Raspberry Pi Camera module, at around 250 kr. To fit this to the Pi Zero I also had to buy a Pi Zero Camera adapter, which cost an additional 50 kr. The camera I chose was the Pi NoIR, which work better in low conditions. To truly provide night vision it requires an IR light source, which I didn’t buy for this project. Finally I needed a mount for the Camera. I choose the ZeroView at 80 kr. The total cost for all equipment (if bought new) would be therefore approximately 680kr. If this seems a lot of money, remember that you can easily reuse the components for other projects at a later point!
  10. We’ll begin by looking at the hardware I used for creating the Camera and how much this costs. The Pi Zero is a cut down version of the Raspberry Pi. They cost about 50kr, but you’ll also need to buy an SD card, power supply and HDMI and USB adapters. Therefore I recommend a starter kit such as the one sold by the Pi Hut. This costs 300 kr, and gives you all you need to get started with the Pi Zero. In addition to the Pi Zero board I needed a camera. I choose the Raspberry Pi Camera module, at around 250 kr. To fit this to the Pi Zero I also had to buy a Pi Zero Camera adapter, which cost an additional 50 kr. The camera I chose was the Pi NoIR, which work better in low conditions. To truly provide night vision it requires an IR light source, which I didn’t buy for this project. Finally I needed a mount for the Camera. I choose the ZeroView at 80 kr. The total cost for all equipment (if bought new) would be therefore approximately 680kr. If this seems a lot of money, remember that you can easily reuse the components for other projects at a later point!
  11. Here you can see the fully assembled camera, from the front and the back. The white cable is a USB Wi Fi adapter and the black cable is for power.
  12. Once I’d gathered the requirements I realized that I needed to implement the above, in a cost effective and speedy manner.
  13. After some consideration, I decided to use the Linux Motion software. Motion is open source, and is purpose built for motion detection. It has excellent performance on the Raspberry Pi Zero, plus a built in web server for streaming video. Detected activity triggers an “event” in Motion, which can be used to send email alerts. Motion works out of the box and is highly configurable. With no need for additional programming it would take no time at all to get up and running.
  14. So how does Motion work? Well it basically monitors the video stream from the camera. Each frame is compared to the previous, in order to find out how many pixels (if any) differ. If the total number of changed pixels is greater than a given threshold, a motion alarm is then triggered.
  15. So how does Motion work? Well it basically monitors the video stream from the camera. Each frame is compared to the previous, in order to find out how many pixels (if any) differ. If the total number of changed pixels is greater than a given threshold, a motion alarm is then triggered.
  16. So how does Motion work? Well it basically monitors the video stream from the camera. Each frame is compared to the previous, in order to find out how many pixels (if any) differ. If the total number of changed pixels is greater than a given threshold, a motion alarm is then triggered.
  17. So how does Motion work? Well it basically monitors the video stream from the camera. Each frame is compared to the previous, in order to find out how many pixels (if any) differ. If the total number of changed pixels is greater than a given threshold, a motion alarm is then triggered.
  18. I was initially very happy with the first version of the Pi Zero Camera. The camera monitored my garden for the whole of July, whilst I was in England with my family. The results from the camera were quite boring, and mostly showed the neighbor's watering our flowers, plus me testing out the camera before we left.
  19. Ok, lets revisit my project requirements. My camera: Would monitor activity in the garden. It would be able to send an email when acitivity was detected. It included a live video stream. It was quick to build and program. It had a one of cost of 680kr. And it was portable. All this led to a happy stakeholder! But was the project completely successful?
  20. False alerts : why problematic? Loads of emails, that’s why!
  21. Ok, let us try a quick demo of the Pi Camera Version 1.
  22. Ok, so lets get started by looking at why I did this project!
  23. You’ll remember these project requirements from earlier on in this presentation. Lets just revisit them all! They are all still just as relevant. But by adding one word to one of the functional requirements we can address the issue of false positives. Any guesses?
  24. Yep. The missing word is “Human”! We only want to send warnings when human activity is detected.
  25. At this point I realised that I had to find an Image Analysis solution. My first idea was to use OpenCV to perform Face Detection on the snapshot images. <click> This type of use of OpenCV is well proven and well documented, and wouldn’t take long to implement. <click> However, it would only work if the subject was facing the camera, and wasn’t wearing a mask! <click> My next idea was to use Googles TensorFlow. This would allow me to create and train a neural network to analyse my images. <click> The downside here is that it would take a considerable investment of time for me to get up and running. This idea was therefore vetoed by my primary stakeholder, who wanted a solution as quick as possible.
  26. Luckily the solution presented itself to me through a random tweet in my twitter feed. <click> It turned out that Arun was talking about Amazon Rekognition, a new Image Analysis solution.
  27. Why cloud based?
  28. Perhaps the best way of understanding what Amazon Rekognition is, is to run a quick demo. DetectLabels use Burglar picture from NTNU folder on my Desktop.
  29. My next challenge was to find out how I would trigger the image processing from my Pi Zero Camera. After some thought I decided to move the whole image processing and email handling to The Cloud, and specifically Amazon Web Services. My planned solution basically looked as follows: The PiZero Camera monitors the garden. On detecting movement, a snapshot is taken and pushed to Amazon Web Services. Amazon web services handles the image analysis and the eventual sending of an alert emails. This solution had some benefits: 1. The Pi Zero could now focus on running the motion software. 2. The Camera and Image Processing would be seperated, making it easy to replace either at a later date. I also tweaked the Motion configuration file to provide multiple snapshots for each detected activity. More pictures would increase the chance of Motion correctly detecting movement.
  30. Ok, so how did the AWS processing work? Here’s a simplified run through. Firstly an image is pushed from the PiZero Camera to Amazon’s s3 storage. A small unit of code or Lambda Function is triggered by the upload. It in turn triggers a Step Function. The Step Function orchestrates further Lambda Functions into a workshop. The first Lambda Function makes a call to Rekognition to evaluate the picture. The second Lambda Function uses the Simple Email Service to send the alert email. Finally, all components in the workflow use Identity Access management to make sure that they have access to the components they need to use. For example, the Lambda Function that sends an email needs access to both the Simple Email Service and to s3 in order to attach the image file to the email
  31. On upload to s3, a Lambda Function is triggered, which in turn triggers a step function, which contains more Lambda Functions. Lets look at AWS Lambda Functions and their role in our solution.
  32. A Lambda Function is essentially a unit of code. As today it is possible to implement Lambda Function using Java, C#, Python and Node.js. Lamba Functions are serverless. This doesn’t mean that they run without servers, but that the business or person running the code doesn’t have to worry about provisioning or managing the servers. In other word, Amazon has responsibility for making sure that the servers are up and running. Lambda Functions are also stateless. By not storing state they are more easily scaled up and down. This scalability is an important part of the Cloud paradigm, as it allows one to scale Lambda Functions rapidly up and down according to demand. The AWS Lambda platform is engineered to be highly available, making it suitable for running applications that need to be up all of the time. AWS Lambda utilises a Pay as you go model. This means that you pay only for the processing time you use. This means that an application with low traffic will be relatively cheap compared to one with lots of traffic. ASW Lambda also has a free tier for those who want to get started with AWS. This provides free usage up to a given threshold. AWS Lambda also has the SDK natively available, making it simple to call other AWS services and resources.
  33. { "s3Bucket": "smart-security-camera-upload", "sendAlert": false, "rekognitionLabels": {}, "s3ArchivedKey": null, "stepFunctionID": "60331694-7476-43c8-b866-8f0ca3d9db2e", "s3key": "archive/falsepositives/gardenCam1/20170904/131601-6069-01.jpg” }
  34. On upload to s3, a Lambda Function is triggered, which in turn triggers a step function, which contains more Lambda Functions. Lets look at AWS Lambda Functions and their role in our solution.
  35. Here is the actual Step Function for my Camera, rendered by the AWS Step Function interface. It’s not necessarily easy to see the flow here, so let me try to shed some light on how this works. The first step submits the snapshot to AWS Rekognition. The second step then evaluates the response from AWS Rekognition. It looks for labels such as “Person” and ”Human” and sets a flag to indicate whether a person has been found. The third step uses this flag to decide whether or not to send an email. Unlike all the other steps this is not calling a Lambda Function. The fourth step sends the alert email if. This will be skipped if the alert flag is set to false. The fifth step archives the snapshot – either in an alert folder or a false positive folder. The final step is an all purpose error handler. Any errors during processing will result in an email being sent to me.
  36. Ok, let us try a quick demo of the Pi Camera Version 2. Show happy case and unhappy case. Show Step Function flow If camera NOT working, try upload from PC : cd '/Users/mark.west/Documents/GitHub Repositories/smart-security-camera/s3-upload/' s3-upload mark.west$ node s3-upload-image-file.js smart-security-camera-upload /Users/mark.west/Desktop/ntnu/burglar.png
  37. Ok, so lets get started by looking at why I did this project!
  38. Ok, lets revisit my project requirements. My camera: Would monitor activity in the garden. It would be able to send an email when human activity was detected. It included a live video stream. It was quick to build and program. It had a one of cost of 680kr. And a yearly cost of 600kr after the first year. And it was portable. All this led to a happy stakeholder! But was the project completely successful?
  39. VAT is 23-25% from what I can see. Some services have a level of free usage for the first year. For example Rekognition allows 5000 pictures a month. S3 also has a certain amount of free usage for the first year. I’m still in my first year, but from december my monthly price will rise by 5-10 dollars a month, including tax. Note that I don’t pay anything for Lambda Function usage – we’ll come to that some.
  40. Ok, let us try a quick demo of the Pi Camera Version 1.
  41. The first figure is based on usage in March, where approximately 3750 images where processed – approximately 125 a day. During this period I received less than 100 real alarms. The second figure is based on the same usage amounts once the free tier is expired. The extra costs will mostly arise from costs of Step Functions and Rekognition, which as new services come at a premium rate. Other than that, additional costs will be incurred by S3 usage.
  42. Ok, so lets get started by looking at why I did this project!
  43. Remind people that we are comparing apples and oranges here, and that both Java and Node.js have places in a modern solution architecture
  44. Reason 2: The AWS Toolkit for Eclipse When creating the Java version of my Smart Security Camera project I used the AWS Toolkit for Eclipse, which provides support for creating, packaging and uploading AWS Lambda Functions. Functions are packaged into ZIP files which also include a set of dependancy JAR files (including the AWS SDK).   Unfortunately the AWS Toolkit isn't selective about which JAR's it adds. A quick analysis of a deployed ZIP file revealed that it included a set of AWS Client JAR's that were not required for that specific Lambda Function to run.  Amending the Maven POM file to remove these unneeded JAR's helped reduce the size of the Java Functions by up to 2MB. Reason 3: Writing Node.js Code Directly in the Browser If your Node.js based AWS Lambda Function doesn't require any 3rd party libraries, you can choose to write your code directly in the browser and avoid the packaging and upload steps. If you do this, the AWS SDK is implicitly available (no need to upload it). In the above table, the four "smallest" functions were all written in this way, which explains their small size. The "largest" Node based AWS Lambda Function was packaged as a ZIP file due to it's dependancy on the Nodemailer library.
  45. Node.js – more free seconds and cheaper price per second. This made me wonder how the costs would differ. Note that my monthly lambda costs are well below the threshold for charging – my total duration per month is normally 10 000 – 15 000 seconds with 40 000 -50 000 executions. Well below the free thresholds.
  46. Remind people that we are comparing apples and oranges here, and that both Java and Node.js have places in a modern solution architecture. Tested 10 times, results remarkably similar from time to time. Have summarized the results and created an average.
  47. Remind people that we are comparing apples and oranges here, and that both Java and Node.js have places in a modern solution architecture. Tested 10 times, results remarkably similar from time to time. Have summarized the results and created an average.
  48. 256MB 1 600 000 $0.00000417
  49. 256MB 1 600 000 $0.00000417
  50. Lambda provides the Amazon Linux build of openjdk 1.8.
  51. Thanks very much for attending my talk! You can find more information about this project at the Bouvet blog. And you’ll find all the code on my GitHub. If anyone wants to have a chat I’ll be on the Bouvet stand for the rest of the day and will be joining some of you for food this evening!