張慎晢
    • 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
    程式碼 --- ```python= import mediapipe as mp import numpy as np import cv2 #將用到的函式庫引入進來 cap = cv2.VideoCapture(0) #讀取影片或鏡頭 mpface = mp.solutions.face_mesh #使用何種模型 face = mpface.FaceMesh(min_tracking_confidence=0.6, min_detection_confidence=0.6) #以mpface呼叫FaceMesh這個函式,可以調整一些參數,按住ctrl滑鼠放solutions上面按右鍵找FaceMesh可看內部參數,()內可以調整數值 #min_tracking_confidence最低的偵測自信度,偵測臉的嚴謹度 #min_detection_confidence最低的追蹤自信度,追蹤臉的嚴謹度,越嚴謹就越要去重新偵測臉的位置 draw = mp.solutions.drawing_utils #將畫座標的函式存進變數 faceLmsStyle = draw.DrawingSpec(color=(0, 0, 255), circle_radius = 1, thickness = 1) #決定點的樣式,circle_radius決定圓的半徑,thickness決定粗度 faceConStyle = draw.DrawingSpec(color=(0, 255, 0), thickness=1) #決定線的樣式 while True: #用while去處理影片的每一幀 ret, img = cap.read() #cap.read()會回傳兩個值,第一個表示讀取影片下一幀是否成功(布林值),第二個為如果有則回傳取得的下一張圖片給我們 rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) #opencv讀取的圖片預設是BGR,更改為RGB result = face.process(rgb) #以process來使用mediapipe所訓練好的模型去處理圖片,並將結果存進result裡面ss imgHeight = img.shape[0] imgWidth = img.shape[1] #讀取圖片的寬高大小 if result.multi_face_landmarks: #如果有偵測到臉的話 for i in result.multi_face_landmarks: #用for迴圈去跑偵測到的每一張臉,把點跟線畫出來 draw.draw_landmarks(img, i, mpface.FACEMESH_CONTOURS, faceLmsStyle, faceConStyle) #用draw呼叫landmarks,把點畫出來,第一個參數是要畫在哪張圖上,第二個把點傳進來 #如果要把點之間做連接則可增加第三個參數,第四個參數設定點的樣式,第五個設定線的樣式 for x, lm in enumerate(i.landmark): #把每個點的座標找出來、印出來 xPos = int(lm.x*imgWidth) yPos = int(lm.y*imgHeight) #lm.x、lm.y為各座標在圖片上的比例位置,乘上圖片寬高大小,就是實際的座標位置 print(x, xPos , yPos , lm.z) #在終端機印出每個點的號碼跟座標 cv2.putText(img, str(x) , (xPos-25 , yPos+5) , cv2.FONT_HERSHEY_SIMPLEX , 0.4 , (0 , 0 , 255), 1) #在哪個影像上、顯示什麼、位置在哪、用甚麼字體、大小、顏色、粗度 cv2.imshow("window", img) #顯示影像 if cv2.waitKey(1) == ord('s'): #以按鍵s中斷影片,()內為影片速度 cap.release() #釋放webcam的資源,避免佔用資源 break cv2.destroyAllWindows() #如果要在眾多openCV視窗下關閉特定視窗,('')帶入視窗名稱即可 ``` 結果 --- ![](https://hackmd.io/_uploads/B101W4Ou2.png) ![](https://hackmd.io/_uploads/Skug-V__3.png) 圖片中的數字依序為:特徵點座標編號(0)、x座標、y座標、z的比例位置

    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