Harden Li
    • 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
    # 積木復健系統 介紹: 積木復健系統是以 CV 為主軸串連後端服務所開發出來的程式,裡面使用傳統影像的 pixel 為16塊積木位置判斷,並以深度學習影像的 YOLO 模型進行積木的辨識與偵測,串聯後端的服務如資料庫 (MySQL) 儲存每一次運行結果,並且以 UI 介面顯示與使用者互動,其中總共撰寫14個檔案串聯,共開發超過30個 function ,以下會介紹開發與使用者的內容。 ## 開發與維護交接 Github 更新 : ``` git init git push https://github.com/s07362022/block_system.git block_system git add . git commit -m "new changes" git checkout -b master1 git push --set-upstream origin master ``` ## MQTT 修改mosquitto.conf設置檔 允許外部裝置連入本機Mosquitto伺服器的辦法是修改mosquitto.conf設置檔,在裡面加入幾個參數,你可以直接修改C:\Program File\mosquitto路徑裡的mosquitto.conf設置檔,筆者是將它命名成mosquitto.conf.bak備份,然後新增一個mosquitto.conf。 ``` allow_anonymous true listener 1883 192.168.0.117 ``` 啟動 ``` mosquitto -c mosquitto.conf -v ``` ## 開發環境: ``` windows 10, Python 3.8.9, MySQL community, install packetge from requirement.txt ``` 程式位置 : [harden github](https://github.com/s07362022/block_system) 1. 建立環境 - MySQL ![](https://i.imgur.com/wfmjqN1.png) 這邊的 Database 請先由MySQL Workbench 操作(較好維護),我們先建立兩個 Database: user, block, user 是為了使用者註冊頁面儲存使用者資訊,block是為了存每次積木系統運行的結果。 ```sql '建立 block :' create database block; show databases; use block; CREATE TABLE `blockbd2`( `id` INT AUTO_INCREMENT, `account` VARCHAR(100) NOT NULL, `Score` VARCHAR(100) NOT NULL, `Time` VARCHAR(100) NOT NULL, `Mode` VARCHAR(20) NOT NULL, `rl` VARCHAR(100) NOT NULL, `nonum` VARCHAR(20) NOT NULL, `cnum` VARCHAR(20) NOT NULL, `boxes` VARCHAR(20) NOT NULL, `time_` VARCHAR(1000) NOT NULL, `strat_time` VARCHAR(1000) NOT NULL, `end_time` VARCHAR(1000) NOT NULL, `sixs` VARCHAR(100) NOT NULL, PRIMARY KEY(`id`) ); ``` ```sql '建立 user ' CREATE TABLE `UserRgeisters`( `id` INT AUTO_INCREMENT, `email` VARCHAR(100) NOT NULL, `username` VARCHAR(100) NOT NULL, `password2` VARCHAR(100) NOT NULL, PRIMARY KEY(`id`) ); ``` 對應 Python 的內容( database=user or block ): ```python import mysql.connector connection = mysql.connector.connect(host='localhost', port='3306', user='root', password='0000', database='user') cursor = connection.cursor() ``` 這裡的 host 是對應電腦當下的 IP,剩下的與你從 MySQL Workbench 建立的資訊是一致的。 2. Py 檔介紹 ![](https://i.imgur.com/p5W4ihe.png) 主要運行是由 controller2.py 控制的,可以直接寫 ```sel python3 controller2.py ``` 由三個 controller.py 控制我們 UI 介面與主程式 main2.py 連接,其中 main2.py 是積木系統操作所有 mode 和 function的檔案,所有要更改的功能都從這邊更改,例如模式的連接: ```python! if mode =='1' # mode 1 表示模式一, mode 2 表示模式二依序 #並且每一個 mode function 一定會呼叫偵測function: frame,flag,box_count,score2=yolo_dec1(frame,classes, scores, boxes,box_count ,mode_1_1,score2,flag) #三個模式所以有三個 yolo_dec1 function ,裏頭都是撰寫每個模式偵測積木與判斷演算法的地方 if flag2 == True #這個判斷是指是否使用者有成功完成這次任務(如請使用者從右盤放到左盤,如果左盤偵測到且演算法判斷成功都匯回傳flag=True)當我們收到 True 的時候就存入資料庫中,紀錄完成後跑下一次的迴圈判斷,值到 60 秒到達。 #以下都是要確認路徑 with open("F:\\Blocks\\yolo\\obj.names", "r") as f net = cv2.dnn.readNet("F:\\Blocks\\yolo\\yolov7-tiny_last.weights", "F:\\Blocks\\yolo\\yolov7-tiny.cfg") #這裡是我們匯入YOLO模型的函式,所以要確定檔案路徑 ``` UI.py 三個檔案分別代表三個介面設計,註冊頁面、登入頁面、使用頁面,如果要更改介面請參考 PyQt5, Qtdesigner 。 read_img.py 可以參考我所設定每個積木在影像上呈現的位置與圓心大小,如果設備的高度與影像有落差可以從這邊直接更改。 3. QA 可能會遇到的問題 Q: python3 controller2.py 還是打不開? A: 檢查py程式裡每一個檔案路徑,確認套件安裝有缺?,大部分於環境設定問題 Q: SQL沒有存到資料? A: 連接設定請跟自己電腦IP與SQL設定一致,請先在自己電腦新建py檔做SQL的測試 Q: YOLO積木偵測不到? A: 調整硬體(光與正上方角度),確認YOLO匯入的檔案路徑是否正確? 如果有問題都可以詢問這裡(共筆) 4. 使用者與使用方法 1.點開檔案: python3 controller2.py / 點選 dist\controller2\controller2.exe 2.先註冊帳號密碼 ![](https://i.imgur.com/4dXgMYX.png) 3.點軟登入頁面登入 ![](https://i.imgur.com/T9gVcu3.png) 4.先點選校正 ![](https://i.imgur.com/uZyk0vB.png) 5.校正過後(積木都對應到藍色圓點位置),點選模式再點選左右手最後案開始 6.開始後,請依照模式操作,隨時可以退出,60秒完成後顯示結果。 待完成事項(5/14): 1. 堆疊積木方法: 設計新 table(每兩秒存一次), 資訊包含積木位置與顏色、當下個數總數,每兩秒做一次前後判段該位置的20pixel範圍內的顏色是否有變動,如果有原本個數+1。 2. 亮燈顯示: 樹梅派連接資料庫得到訊號,利用電路的xor扎試做電路。

    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