WesleyCh3n
    • 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
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: NTU-IoT-Cow --- # NTU-IoT-Node [![WesleyCh3n - ntu-IoT-node](https://img.shields.io/badge/WesleyCh3n-NTU--IoT--Node-2ea44f?style=for-the-badge&logo=github)](https://github.com/WesleyCh3n/NTU-IoT-Node) ![Docker - cross-compile](https://img.shields.io/badge/Docker-cross--compile-informational?style=for-the-badge&logo=docker) ![OS - Raspberry Pi](https://img.shields.io/badge/OS-Raspberry_Pi-blue?style=for-the-badge&logo=Raspberry+Pi) ![Made with - C++](https://img.shields.io/badge/Made_with-C%2B%2B17-informational?style=for-the-badge&logo=C%2B%2B) ![TFLite - 2.4.1](https://img.shields.io/badge/TFLite-2.4.1-informational?style=for-the-badge&logo=Tensorflow) ![Bash - 5.0.3](https://img.shields.io/badge/Bash-5.0.3-informational?style=for-the-badge&logo=gnu-bash) This is NTU BME MS thesis project. The purpose of this project is using edge device (Rpi) to monitoring dairy cow feeding behavior. The code is focus on streaming also recognizing individual cow faces by edge computing (with Tensorflow Lite etc). This repo contains c++ and python version. *The python version is deprecated, but still usable*(in `python` branch). The main program uses c++. ## Usage ```bash $ ntu-node -h NTU BBLAB cow face monitoring system Usage: ntu-node [OPTION...] -s, --stream Start streaming -i, --image arg image directory to recognize (default: ) -D, --detect arg detect model path (default: ./model/yolov4-tiny-f16.tflite) -C, --classify arg classify model path (default: ./model/mobilenetv2.tflite) -n, --node arg node number (default: ) -r, --ref arg class reference (default: ./cfg/ref.8f.tsv) -d, --ref_dict arg class id (default: ./cfg/ref_dict.csv) -f, --fence arg fence bbox (default: ) -m, --mqtt_ip arg mqtt broker ip (default: ) -u, --user arg mqtt username (default: ) -p, --pwd arg mqtt password (default: ) -v, --version ntu-node version -h, --help Print usage ``` ## Build ### Platform - os: Raspbian GNU/Linux 10 (buster) - kernel: 5.4.51-v7l+ / 5.10.60-v8+ ### Prerequisites All libraries are built in static and default location is placed in `/opt/`. Or, modify `CMakeLists.txt` to the correct folder you built. | Library | Pre-built Link | |:------------------------------------------------ |:----------------------------------------------------------------------------------------:| | [OpenCV](https://bit.ly/2Y8KyJK): 4.5.1 | [✔️](https://drive.google.com/file/d/1-HfoQ7DWhVF3rPNbOTsw3kopCuwh7h2H/view?usp=sharing) | | [Tensorflow Lite](https://bit.ly/3ytc6Wu) | [✔️](https://drive.google.com/file/d/1RcNIygC6bi8E5EsYmM1a2YKjioC5iFZE/view?usp=sharing) | | [CXXopts](https://bit.ly/3sU28MO): 2.2.1 | [✔️](https://drive.google.com/file/d/1VU4EA80AE_xNnJDVePAJEUNmqPtHWcps/view?usp=sharing) | | [MQTT](https://github.com/eclipse/paho.mqtt.cpp) | [✔️](https://drive.google.com/file/d/1BOVi3j5v8offJPDaFkm6jIUpn9Gw38va/view?usp=sharing) | | [Boost](https://bit.ly/2UX4A8J): 1.75.0 | [✔️](https://drive.google.com/file/d/1IJhaDof-paWjeXAZWeOmyLD-co-j-6Vs/view?usp=sharing) | For OpenCV, extract and cp `opencv/lib/pkgconfig/opencv4.pc` to your `$PKG_CONFIG_PATH` (default: `/usr/lib/pkgconfig/`). Then type `pkg-config --list-all|grep opencv` and if you see ```bash=! $ pkg-config --list-all|grep opencv opencv4 OpenCV - Open Source Computer Vision Library ``` OpenCV is set up. Finally, go to `/opt/` and extract all then good to go. ### RPi Native Compiling Clone the project to the Raspberry Pi. And cd to cc/recognition/ then compile. Make sure your prerequisites are built. ```bash git clone https://github.com/WesleyCh3n/NTU-IoT-Node cd && NTU-IoT-Node mkdir build && cd build cmake ../src/ ``` you will see something like ```bash -- The C compiler identification is GNU 8.3.0 -- The CXX compiler identification is GNU 8.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/local/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/local/aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") -- Checking for module 'opencv4' -- Found opencv4, version 4.5.0 -- NTU IOT NODE: -- VERSION = beta -- FOUND ARCH: arm64v8 -- Configuring done -- Generating done -- Build files have been written to: /work/arm64/ntu-node ``` make sure `ARCH` is the architecture you want to perform (in this example, aarch64 is built) After cmake complete, start compile by (-j<number of thread>) ```bash make -j4 ``` once finished, you will get following output ```bash [ 20%] Building CXX object cow_monitor/yolov4-tiny_lib/CMakeFiles/yolov4-tiny.dir/yolov4-tiny.cc.o [ 20%] Building CXX object cow_monitor/network_lib/CMakeFiles/network.dir/network.cc.o [ 30%] Building CXX object cow_monitor/mobilenetv2_lib/CMakeFiles/mobilenetv2.dir/mobilenetv2.cc.o [ 40%] Linking CXX static library libnetwork.a [ 40%] Built target network [ 50%] Linking CXX static library libmobilenetv2.a [ 50%] Built target mobilenetv2 [ 60%] Linking CXX static library libyolov4-tiny.a [ 60%] Built target yolov4-tiny [ 70%] Building CXX object cow_monitor/CMakeFiles/cow_monitor.dir/cow_monitor.cpp.o [ 80%] Linking CXX static library libcow_monitor.a [ 80%] Built target cow_monitor [ 90%] Building CXX object CMakeFiles/ntu-node.dir/main.cc.o [100%] Linking CXX executable ntu-node [100%] Built target ntu-node ``` Then the folder should have `ntu-node` binary. ### Cross Compiling TODO ### Docker Testing After compiling complete, you can use the docker image to verify on RPi. For arm32v7: [docker image](https://hub.docker.com/layers/arm32v7/debian/stable-slim/images/sha256-7bb9de2067f4e4e3e2377070e180a05d33a0bc4289c66b9e71504063cf18da15?context=explore) ```bash $ docker run -it --rm --privileged=true \ -w /home/ \ -v `pwd`:/home/ \ --device=/dev/video0 arm32v7/debian:stable-slim bash ``` For arm64v8: [docker image](https://hub.docker.com/layers/arm64v8/debian/stable-slim/images/sha256-051adf1212e6a3ba39a13a02afd690a81e6422461b81042c35c74ae9cc8ed272?context=explore) ```bash $ docker run -it --rm --privileged=true \ -w /home/ \ -v `pwd`:/home/ \ --device=/dev/video0 arm64v8/debian:stable-slim bash ``` Then ```bash ./ntu-node -h ``` --- ## `upload.sh` ### Usage ```bash $ ./upload.sh \ -u rsync_user \ -p rsync_ip \ -P rsync_port \ -d remote_folder \ # must have NODE+02d in the path to know which node is it -t backup_time_interval(s) ``` for example ``` $ ./upload.sh \ -u root \ -p 255.255.255.255 \ -P 22 \ -d /data/dir/NODE00/ \ -t 600 ```

    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