View output in AWS IoT
- Go to AWS IoT console at https://console.aws.amazon.com/iot/home
- Under Subscription topic, enter the topic name that you entered as an environment variable for the Lambda function you created in the earlier step (example: worker-safety-demo-cloud) and click Subscribe to topic.
- You should now see JSON message with a list of people detected and whether they are wearing safety hats or not.
View output in Amazon CloudWatch
- Go to Amazon CloudWatch Console at https://console.aws.amazon.com/cloudwatch
- Create a dashboard called “worker-safety-dashboard-your-name”
- Choose Line in the widget
- Under Custom Namespaces, select “string”, “Metrics with no dimensions”, and then select PersonsWithSafetyHat and PersonsWithoutSafetyHat.
- Next, set “Auto-refresh” to the smallest interval possible (1h), and change the “Period” to whatever works best for you (1 second or 5 seconds)
View output in the web dashboard
- Go to AWS Cognito console at https://console.aws.amazon.com/cognito
- Click on Manage Identity Pools
- Click on Create New Identity Pool
- Enter “awsworkersafety” for Identity pool name
- Select Enable access to unauthenticated identities
- We are using Unauthenticated identity option to keep things simple in the demo. For real world applications where you only want authorized users to access the app, you should configure Authentication providers.
- Click Create Pool
- Expand View Details
- Under: Your unauthenticated identities would like access to Cognito, expand View Policy Document and click Edit.
- Click Ok for Edit Policy prompt.
- Copy JSON from cognitopolicy.json and paste in the text box.
- Click Allow
- Make a note of the Identity Pool as you will need it in the following steps.
- Go to AWS IoT in AWS Console at: https://console.aws.amazon.com/iot
- Click on settings and make a note of the endpoint, you will need this the following step.
- Download webdashboard.zip and unzip on your local drive.
- Edit aws-configuration.js and update poolId with Cognito Identity Pool Id and host with IoT EndPoint you got in the earlier steps.
- From the terminal go to the root of the unzipped folder and run “npm install”
- Next, run “./node_modules/.bin/webpack —config webpack.config.js”
- This will create a build that we can easily deploy.
- Go to Amazon S3 bucket, and create a folder titled “web”
- From the web folder in S3 bucket, click upload and select bundle.js, index.html and style.css.
- From Set permission, Choose Grant public read access to the objects. and click Next
- Leave default settings for following screens and click Upload.
- Click on index.html and click on the link to open the web page in browser.
- In the address URL append ?iottopic=NAME-OF-YOUR-IOT-TOPIC. This is the same value you added to the Lambda environment variable and hit Enter.
- You should now see images coming in from AWS DeepLens with a green or red box around the person. Green indicates the person is wearing a safety hat and red indicates a person who is not.
This completes the application- you have now learnt to build an application that detects if a person at a construction site is wearing a safety hat or not. You can quickly extend this application to detect lab coats or helmets etc.
Before you exit, make sure you clean up any resources you created as part of this lab.
Delete Lambda functions, S3 bucket and IAM roles.