TimHsuTW
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Object detection using AWS Greengrass + QIoT Suite Lite + QuAI using Raspberry Pi Camera (English) You need to prepare : 1. AWS Accont 2. Raspberry Pi 3. USB webcam ## Scenario-1 * Camera --> AWS Greengrass IoT device --> AWS Greengrass Core --> QIoT Suite Lite --> QuAI --> AWS Greengrass Core Lambda --> AWS Cloud --> AWS S3 bucket ![](https://lh5.googleusercontent.com/aoo3W42OK2QebVCYr6vnbVwPRHK00sxDlAQu5bo2--lQGLcmWWBdzyaj1f6d4KtAu6v3WuZenbea6YCbKFUqiz-csn-xhOMyf93wz6mJGumqTe0RjujgxCEwPC-mv0cbL-m7Im4) ### Step-1 : Prepare AWS Greengrass Core 1. Install AWS Greengrass App in QNAP NAS from App center ![](https://lh3.googleusercontent.com/T3tEtqax5wHzvUPxGyAsi9OM3sdI7MS3teIB4yIM3drB89B1gvjJ8T2mMbjW9mpsq9k7jXPceKhufaRKMKGihM46ONxW56S0KkRKWmjJXinufn7czXFr2pP7jL9gZUBHUs0MUQY) 2. Setup your AWS Greengrass Group & Core in QNAP AWS Greengrass App. Please refer this link for more details : https://www.qnap.com/en/how-to/tutorial/article/how-to-setup-aws-greengrass-on-qnap-nas/ 3. Create **"SendGGImageToQIoT"** & **"QIoTIntegration"** AWS Greengrass Lambda functions as shown below. For this Demo we are using Node.js based Lmabda function. You should also update it's configuration setting's Memeory limit and timeout. Please find Demo Lambda source codes inside this folder [AWS_Greengrass_Lambda](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/Greengrass_device_QIoT_QuAI/AWS_Greengrass_Lambda). (建立Lambda function請參考AWS說明文件 : https://docs.aws.amazon.com/greengrass/latest/developerguide/create-lambda.html) ![](https://lh6.googleusercontent.com/25L0HDAsmD3lvlnwPQ_-wdldMx97gf51xCXIOys5ecNO-SeD431zT7raB16Zi31L9vXbXwD4-HMotYdbREds8qz7BO8d-ZS_O8rwUlTqM6u6eOw1KoZ4U2EEIKIAcUdU6f9LI8M) ![](https://lh6.googleusercontent.com/58pe_n7cZQSkKhdiyq_m30_2_Kzgu6GLxHrI1g9dgk_ZjSUqkQHFfKJ21aylYhLLYxKtFo48RoEtD2_-NQhIxNp5YbX1iyVr8tLhgN8wo7v4fKXvkbc_5CZegkypYMMzUsjK5Wg) 4. Create a new device inside Greengrass Group Devices section as shown in the below image. Reference : [https://docs.aws.amazon.com/greengrass/latest/developerguide/device-group.html](https://docs.aws.amazon.com/greengrass/latest/developerguide/device-group.html) **<font color=red># Notes : Please keep your device certificates, unzip it and upload to your Raspberry Pi.</font>** ![](https://lh4.googleusercontent.com/HQ9zM0YtiJWGb9PFW91_70qj_wB6RKd-Gt5jdZHYLAH4vY0HVKqgG_PLNdHF-LYUFhXailJcIamMgwOldPxjlXrap_vibz2Xu7noNn5rDHybcHeBWfdJiuRrdXyr_9v-npM28e0) 5. Prepare following 3 subscriptions lists * Greengrass IoT Device to **"SendGGImageToQIoT:9"** Lambda for Image Prediction. Setting infomation : * Source --> **GG_Camera** * Target --> **SendGGImageToQIoT** * Topic --> **cameraImage** * **"QIoTIntegration"** Lambda function to IoT Cloud for upload predicted image to S3 Bucket. Setting infomation : * Source --> **QIoTIntegration** * Target --> **IoT Cloud** * Topic --> **#** * Greengrass IoT Device to **"QIoTIntegration:16"** Lambda is trigger Lambda to start. Setting infomation : * Source --> **GG_Camera** * Target --> **QIoTIntegration** * Topic --> **triggerLambda** Please refer the following image for these 3 subscriptions list source, destination and topic details ![](https://lh4.googleusercontent.com/izAtzHGnuMAQ9nQv6HmLLuRiPd5w1Xz_gx9biRv16oTlkEZj0WCQPETUIUqEX9mQB1Z4UPwBIU0jGu1ITmLSYNgBL0T2Hk7pq9wynJkE0WhvWpQy6rVWyeplo23rwn3jJZ6m-xk) 6. Deploy the Greengrass Group. ![](https://lh4.googleusercontent.com/p56Qc4HF45UO3jABY6TnQmLXAmBfQq_nqH-UkE6G7m8qaeEiWTSczwB0n5BTLluVYTIMcW5D27D8IYMishnIhai5fP61My3f-nCGINv_L4BUbhHB_VGeBSpw7jVWdj_OkwhBFNg)</span> 7. Verify Greengrass core daemon status in QNAP Greengrass App ![](https://i.imgur.com/8TsiGYx.png) 8. Trigger the QIoTIntegration Lambda function to receive QIoT Suite Lite message. So that, you have to download AWS IoT Python SDK --> [**basicDiscovery.py**](https://github.com/aws/aws-iot-device-sdk-python/blob/master/samples/greengrass/basicDiscovery.py) and execute the following command. Please use **GG_Camera** device certificate files to trigger this Lambda function 9. Run this Command : ```bash python basicDiscovery.py -e <youtiothostname>.iot.<region>.amazonaws.com -r root-ca.pem -c XXXXXXXX.cert.pem -k XXXXXXXX.private.key -n GG_Camera -m publish -t triggerLambda -M "{'status':'start'}" ``` - **-e** : Aws IoT Endpoint (In **IoT Core** home page, under **Settings**, make a note of the value of **Endpoint**.) - **-r** : Root CA Path (In here : https://docs.aws.amazon.com/iot/latest/developerguide/managing-device-certs.html) - **-c** : Thing Ceritificate Path - **-k** : Thing Private key Path - **-n** : Thing Name ### Step-2 : Setup AWS Greengrass IoT Device Install **AWSIoTPythonSDK** package in your Raspberry Pi **(Refer to the instructions here for installation : https://docs.aws.amazon.com/greengrass/latest/developerguide/IoT-SDK.html)** and deploy the **"send_image_AWSGG.py"** source code from this folder [**RaspberryPi_side**](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/Greengrass_device_QIoT_QuAI/RaspberryPi_side) to Raspberry Pi and install capture software. Command is : ```bash sudo apt update && sudo apt install fswebcam ``` ### Step-3 : Setup Demo QuAI 1. 開啟NAS上的Container Station 2. 切換到 **Crtare** 頁面,於搜尋列搜尋 **"qeekdev/aipredict"** 3. 點選 **Install** 進行安裝 ![](https://i.imgur.com/q1Ps54Y.png) 4. 點擊 **Advanced Settings** 進入進階設定頁面 ![](https://i.imgur.com/7E6RKvt.png) 5. 切換到 **Network** 頁面設定Port,參考下圖設定(若您有服務與此Port相衝突到,請自行更換),完成後請點擊 **Create** 建立容器 : ![](https://i.imgur.com/sIWTvu3.png) 4. 建立完成後,位於左邊的 **Overview** 功能項目裡,可檢視剛建立完成的新容器,該容器功能為AI辨識照片的服務。 ![](https://i.imgur.com/H8FtewP.png) ![](https://i.imgur.com/Y4XPQwL.png) 5. 瀏覽器進入 http://\<IP\>:8082/api/v1/ 進行測試,操作結果如下 : ![](https://i.imgur.com/F91rKZG.png) ![](https://i.imgur.com/Ovz8LZv.png) ***其他佈署資訊可參考Dockerhub上的頁面 : https://hub.docker.com/r/qeekdev/aipredict/*** ### Step-4 : Setup QIoT Suite Lite Create a new IoT Application in QIoT Suite Lite from the Application template file [**LiveDemo.json**](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/Greengrass_device_QIoT_QuAI/QIoT_IoT_App) import to QIoT Suite Lite or you may create a new IoT Application by yourself. To do so, please follow following steps **<font color=red># Notes : You need to install “[node-red-contrib-file-upload](https://flows.nodered.org/node/node-red-contrib-file-upload)” module to your QIoT Suite Lite Rule, Reference to : [How to install other modules in QIoT Suite Lite NodeRED?](https://www.qnap.com/go/how-to/tutorial/article/how-to-install-other-modules-in-qiot-suite-lite-nodered)</font>** 1. Create an IoT App and 2 Things : **"cameraPi"** and **"AWSgreengrass"** ![](https://lh6.googleusercontent.com/JRMA3WIlr0kOcAeolsC8K-jLxNwzI5zaZlhBqI1BvaUyBgKSFvvDcg4prHw7Eun70oJekbyRBn0tiGCTxcatn8a9Tz9WWc8qbMlBewyP97dnjVge4g70cc3LXjZk-1WFe3PCRTg) 2. And create Thing Resource : **cameraPi-->"image"** and **AWSgreengrass-->"resolve"** ![](https://i.imgur.com/PM18eDQ.png) ![](https://i.imgur.com/AlJ872J.png) 3. Import [**rulesJson.json**](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/Greengrass_device_QIoT_QuAI/QIoT_IoT_App) in Node-Red rule engine using Rules tab --> Import --> Clipboard option. After import you can see the following 2 rules flow ![](https://lh6.googleusercontent.com/Za0OytH3y7ghKJzf5DjHOjKRlLIkmT9j_fiyYYRzZ-Zj4eMUPFMcc39NzKA-9cA_e8qiOD5Tth0frvq3RpDZJLLoW0GyanlwwsjBVP5rQ-r3v-lp-tKsxA4a4rYEsQ0U2TSDvyc) ![](https://lh4.googleusercontent.com/DzNaHMykwGYKoiZvC_EOiAdlxyZEAl3RgqpVvt2y8rRSVmfCQLX6uJFWPHiSSoWrXGoRNzheZiOiZqpim26SM47LH4xf2-zV_MPXA3vCH_NeDSGVlhifniGLxzzqM6WQ8tfizks) 4. Verify your dashboard * 點擊下圖紅框處測試 Dashboard 、 AI Sample Container 和 AWS Greengrass是否有正常運作 ![](https://i.imgur.com/UYyaOfq.png) * 觀看右側Debug欄位是否有出現正常log ![](https://i.imgur.com/378lUyo.png) * 切換到Dashboard頁面是否有呈現數值及照片 ![](https://i.imgur.com/TEI7ScB.png) ### Step-5 : Setup AWS cloud S3 bucket & Rules 1. Create **MoveImageToS3** Node.js Lambda function in AWS Lambda service. **(Please find Demo Lambda source codes inside this folder [AWS_Greengrass_Lambda](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/Greengrass_device_QIoT_QuAI/AWS_Greengrass_Lambda))**(建立Lambda function請參考AWS說明文件 : https://docs.aws.amazon.com/greengrass/latest/developerguide/create-lambda.html) 2. Create a new S3 bucket **"qiotquaiggdemo"** in AWS S3 service (建立S3 bucket請參考AWS說明文件 : https://aws.amazon.com/s3/getting-started/?nc1=h_ls) 3. 參考下圖修改Lambda Function中的S3 Bucket設定,依據您的AWS IAM及S3上的設定填入accessKeyId、secretAccessKey、Bucket等資訊: ![](https://i.imgur.com/RrNTrqC.png) 4. Create a Act(rule) in AWS IoT to upload Image to S3 bucket using Rule's action **"Invoke a Lambda function passing the message data"** ![](https://lh3.googleusercontent.com/LzmfyLP9fgCHpl_UzO7UuYFp5GC_iOE89xv-HSfvr71IXjUt2JI299Dn1W_dREIrTIAVkcLEKuZEbbl4EUQsoZVCigKteRSTnab0nEwqg1yQ9vWfOa_TsXIgHyGXLRWVK7dZzHQ) ![](https://lh6.googleusercontent.com/KooGSOAGpji2f8GMaxhXdPKnd7XhqVSdJ5ThQATV46Q5TfwmcRIxCLIBQGq78HOGB0mpCj0vP5EQZDgwHQBuEJpaFFZNbLbufG9qQifLWi56Kul_2WM0Dt1UNtkPg0tl6d3b9Fo) 5. Declare **MoveImageToS3** in the function name drop down and update the changes ![](https://lh3.googleusercontent.com/EXlN0yjPK3SSYAkr05qbAynrP9swgapkX-kAPLoHuUEgumwsVKwnmuk7iPpNdXkzMXaawE2jfxy9V0aMK19hQ660L40f-pRE_BswbfqxaxJRWVfxry_vcCjcCinUnCAVvdetPPw) ![](https://lh4.googleusercontent.com/t-5PBES_Nic52i3tpj2euX_v51eQQ-gt9TLpzIotc1Wqwc2MMuFxqaEYs3e4_llwLHYnBuU3yx7XkvXslxQUkX3jQUboy4JU9NXRGelYTZuzuAfd6xPWX5jhH-vPRbWZ4o1v6BU) ### Step-6 : Start the demo Setup the camera in Raspberry Pi device and start the program by executing the following command : ```bash python send_image_AWSGG.py -e <host>.iot.<region>.amazonaws.com -r root.ca.pem -c <GG_Camrea_Cert_pem_file> -k GG_Camrea_Cert_private_key_file -n GG_Camera -m publish -t "cameraImage" ``` - **-e** : Aws IoT Endpoint (In **IoT Core** home page, under **Settings**, make a note of the value of **Endpoint**.) - **-r** : Root CA Path - **-c** : Thing Ceritificate Path - **-k** : Thing Private key Path - **-n** : Thing Name ### Step-7 : Verify the demo 1. In QIoT Suite Lite Dashboard : ![](https://i.imgur.com/8Y2MzYM.png) 2. In AWS IoT Cloud : ![](https://i.imgur.com/bvvR3t2.png) 3. In AWS S3 : ![](https://i.imgur.com/Pr5B0g7.png) ## Scenario-2 * Camera --> QIoT Suite Lite IoT device --> QIoT Suite Lite --> QuAI --> AWS Greengrass Core Lambda --> AWS Cloud --> S3 bucket ![](https://lh6.googleusercontent.com/HmfJ0dfu50Pxr9dNL9x2bXY-JuhE6On5YRT4FGRbk_8nBc1WpucgpTZZROJOgHLuzuAEmi1qQmVT9LrpgtHYdLU4NZo2qdUKNNvgyNWoZATiN668vuC0x8TyX8FePdK5N3PnIh4) The steps in this scenario are same as Scenario-1, just that the application running on Raspberry Pi is different. Please refer **[QIoT_device_QuAI_Greengrass](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/QIoT_device_QuAI_Greengrass/)** section to setup the device. 參考步驟 : 1. Install dependency library and software ```bash pip install paho-mqtt sudo apt update && sudo apt install fswebcam ``` 2. Follow in **Scenario-1**--> **"Step-1"** to **"Step-5"** 3. Upload **[RaspberryPi_side](https://github.com/qnap-dev/qnap-qiot-sdks/tree/master/projects/AWSGreengrass-Integration-Scenarios/QIoT_device_QuAI_Greengrass/RaspberryPi_side)** floder to Raspberry Pi 4. Download **"resourceinfo.json"** from QIoT Suite Lite **cameraPi** thing and put **resourceinfo.json** under the "/res" folder 5. Run command : ```bash python main.py ``` 6. Follow in **Scenario-1**--> **"Step-7"** ###### tags: `Tutorial`

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully