Hong En
    • 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
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
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
  • 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Lab18 Camera with YoloV8 ## 2024教育部計劃 實驗二 ## 版本 * rpiOS 64bit * ## 安裝相機模組 https://youtu.be/GImeVqHQzsE?si=7L95tqPVCRvB3jW9 * 先打開相機阜的卡榫。這個卡榫要兩邊同時施力拉起,注意不要太大力,只能拉起來 1~2 mm 而已。 * 接著將相機排線插入,一樣不用太大力,輕輕地就可以了。小心不要折到排線。 * 插入後再將卡榫蓋回即可,注意排線要平整的插入,不可以左右不一樣高。 ## 相機測試 ``` #會跑五秒的測試 rpicam-hello ``` ![image](https://hackmd.io/_uploads/BkB4Em726.png) 看到這個畫面就是正常的(如果rpi有接螢幕的話會有相機畫面) ## 使用指令拍照 ``` # 會跑五秒中之後拍照,檔案名稱為test.jpg rpicam-jpeg -o test.jpg # 可以加上-t參數來控制要延遲多久拍照 單位是微秒 rpicam-jpeg -o test.jpg -t 3000 # 延遲三秒後拍照 rpicam-jpeg -o test.jpg -t 1 # 秒拍 ``` * 透過vscode的介面來查看圖片 * 參數控制 * -O : 輸出檔案名稱路徑 * -t : 再多少毫秒之後拍照 預設是5000 * --width :寬度 最大4608 * --height: 高度 最大2592 * --shutter: 曝光時間 單位微秒(0.001毫秒-) * 也可以調整亮度、旋轉、反轉等等 可以用 `rpicam-jpeg -h` 查看 ![image](https://hackmd.io/_uploads/BJ9EDmQ36.png) ![image](https://hackmd.io/_uploads/BJfrPmXnT.png) ## 使用指令錄影 ``` rpicam-vid -t 10000 -o test.h264 # 把.h264檔下載到電腦可以看 ``` ## 使用python控制鏡頭 ``` python from picamera2 import Picamera2, Preview import time picam2 = Picamera2() camera_config = picam2.create_preview_configuration() picam2.configure(camera_config) picam2.start() out = picam2.capture_file("test2.jpg") print((out)) ``` ## 安裝 ``` pip install ultralytics --break-system-packages ``` ## 使用yolo作影像辨識 先執行`rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888`後在執行下面的python ``` from ultralytics import YOLO model = YOLO('yolov8n.pt') res = model.predict('tcp://127.0.0.1:8888', show=True) ``` ## 自行設定訓練資料集 https://app.roboflow.com/ ![image](https://hackmd.io/_uploads/r1ERtjMx0.png) * 先建立一個新的project,可以自行為他命名 ![image](https://hackmd.io/_uploads/SyFgciGxR.png) * 上傳圖片至project * 完成後點選右上角save and continue ![image](https://hackmd.io/_uploads/HyIA9jMeR.png) * 點選 start manual labeling 後 assign image 給自己 * 接著就可以點start annotation 來標註自己的圖片了 ![image](https://hackmd.io/_uploads/Hk26joMeR.png) * 右邊有一些工具可以用,預設是只用box 來框選,也可以改成不規則,並自行設定label * 完成後點選左上角的箭頭,並點選右上角的add to dataset ![image](https://hackmd.io/_uploads/ryq2w3QeR.png) * 可以根據你想要的比例來切割資料集 * train: 用來訓練的資料 * validation: 訓練過程中驗證結果的資料 * test: 訓練完畢後用來評估模型好壞的資料 * 通常是70%/20%/10% 的比例 ![image](https://hackmd.io/_uploads/ryGi5h7lR.png) * 接著點選左邊的generate 就可以來製作資料集了 * 可以自行設定前處理(preprocessing)以及資料增強(augmentation)的方式 * 注意設定時要考慮到是否合理,例如要做數字辨識的時候不能左右或上下翻轉 * 可以每個都玩玩看 * ![image](https://hackmd.io/_uploads/SyIQon7gC.png) * 最後可以選擇要生成多少的圖片作為資料,免費仔最多只能生成原始資料的三倍 * 完成後點選右上角的export dataset,選擇yolov8,並選取download zip to computer * 就可以得到資料的zip檔了,解壓縮後就可以丟上google colab 進行訓練 ## colab 訓練自訂模型 https://drive.google.com/file/d/1OaicYnzy8BHtesrXrFd7KI7xep9AhqdG/view?usp=drive_link https://colab.research.google.com/drive/16tDFRCITekb53MrcX2wIz48Hj1iER_Fk?usp=sharing ## 使用自訂yolo模型作影像辨識 先執行`rpicam-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888`後在執行下面的python ``` from ultralytics import YOLO // 要把模型的檔案名稱換成剛剛訓練的檔案名稱 model = YOLO('yolov8n.pt') res = model.predict('tcp://127.0.0.1:8888', show=True)

    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