แนวคิดการตรวจจับใบหน้า
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
การตรวจจับใบหน้าจะค้นหาใบหน้าของมนุษย์ในสื่อแบบภาพ เช่น ภาพหรือวิดีโอดิจิทัล เมื่อระบบตรวจพบใบหน้า ใบหน้าจะมีตำแหน่ง ขนาด และการวางแนวที่เกี่ยวข้อง และสามารถค้นหาจุดสังเกตต่างๆ เช่น ตาและจมูก
ตัวอย่างคำที่เราใช้เกี่ยวกับฟีเจอร์การตรวจจับใบหน้าของ ML Kit มีดังนี้
การติดตามใบหน้าขยายการตรวจจับใบหน้าไปยังลําดับของวิดีโอ ทุกใบหน้าที่ปรากฏในวิดีโอไม่ว่าระยะเวลาใดก็ตามสามารถติดตามได้จากเฟรมหนึ่งไปยังอีกเฟรมหนึ่ง
ซึ่งหมายความว่าใบหน้าที่ตรวจพบในเฟรมวิดีโอต่อเนื่องกันสามารถระบุได้ว่าเป็นบุคคลคนเดียวกัน โปรดทราบว่านี่ไม่ใช่การจดจำใบหน้ารูปแบบ การติดตามใบหน้าจะอนุมานตามตำแหน่งและการเคลื่อนไหวของใบหน้าในลำดับวิดีโอเท่านั้น
จุดสังเกตคือจุดสนใจภายในใบหน้า ตัวอย่างจุดสังเกตต่างๆ คือตาซ้าย ตาขวา และฐานจมูก ML Kit ให้ความสามารถในการ
ค้นหาจุดสังเกตบนใบหน้าที่ตรวจพบ
คอนทัวร์คือชุดของจุดที่ติดตามรูปร่างของลักษณะใบหน้า
ML Kit ให้ผู้ใช้ค้นหาส่วนโค้งของใบหน้าได้
การจำแนกประเภทจะระบุว่ามีลักษณะเฉพาะบนใบหน้าหรือไม่ ตัวอย่างเช่น ใบหน้าสามารถจำแนกได้ตาม
การหลับตาอยู่ ยิ้มใบหน้าอยู่
การวางแนวของใบหน้า
คำต่อไปนี้อธิบายมุมที่ใบหน้าของคุณหันไปข้างกล้อง
- ออยเลอร์ X: ด้านที่มีมุมบวกออยเลอร์ X หงายขึ้น
- ออยเลอร์ Y: ใบหน้าที่มีมุมออยเลอร์ Y เป็นบวกคือมองทางด้านขวาของกล้องหรือมองไปทางซ้ายหากเป็นลบ
- Euler Z: ใบหน้าที่มีมุมบวกออยเลอร์ Z จะหมุนทวนเข็มนาฬิกาโดยสัมพันธ์กับกล้อง
ML Kit ไม่รายงานมุมออยเลอร์ X, ออยเลอร์ Y หรือออยเลอร์ Z ของใบหน้าที่ตรวจพบเมื่อ
LANDMARK_MODE_NONE
, CONTOUR_MODE_ALL
, CLASSIFICATION_MODE_NONE
และPERFORMANCE_MODE_FAST
มีการตั้งค่าเข้าด้วยกัน
จุดสังเกต
จุดสังเกตคือจุดสนใจภายในใบหน้า ตาซ้าย ตาขวา และฐานจมูกล้วนเป็นตัวอย่างของจุดสังเกต
ML Kit ตรวจจับใบหน้าได้โดยไม่ต้องมองหาจุดสังเกต
การตรวจจับจุดสังเกตเป็นขั้นตอนที่ไม่บังคับซึ่งปิดใช้โดยค่าเริ่มต้น
ตารางต่อไปนี้สรุปจุดสังเกตทั้งหมดที่ตรวจจับได้ด้วยมุมออยเลอร์ Y ของใบหน้าที่เกี่ยวข้อง
มุมออยเลอร์ Y |
จุดสังเกตที่ตรวจพบ |
< -36 องศา |
ตาซ้าย, ปากซ้าย, หูซ้าย, ฐานจมูก, แก้มซ้าย |
-36 องศาถึง -12 องศา |
ปากซ้าย, ฐานจมูก, ปากล่าง, ตาขวา, ตาซ้าย, แก้มข้างซ้าย, จุกหูซ้าย |
-12 องศา ถึง 12 องศา |
ตาขวา, ตาซ้าย, ฐานจมูก, แก้มซ้าย, แก้มขวา, ปากซ้าย, ปากขวา, ปากล่าง |
12 องศา - 36 องศา |
ปากขวา, ฐานจมูก, ปากล่าง, ตาซ้าย, ตาขวา, แก้มขวา, จุกหูขวา |
> 36 องศา |
ตาขวา, ปากขวา, หูขวา, ฐานจมูก, แก้มขวา |
จุดสังเกตที่ตรวจพบแต่ละรายการจะมีตำแหน่งที่เกี่ยวข้องในรูปภาพ
คอนทัวร์
เส้นโครงร่างเป็นชุดของจุดที่แสดงรูปร่างของลักษณะใบหน้า รูปภาพต่อไปนี้แสดงวิธีการที่จุดเหล่านี้จับคู่กับใบหน้า คลิกที่รูปภาพเพื่อขยาย
เส้นโครงร่างแต่ละจุดที่ ML Kit ตรวจพบจะแทนด้วยจำนวนจุดที่แน่นอนดังนี้
ใบหน้ารูปวงรี |
36 คะแนน |
ริมฝีปากบน (ด้านบน) |
11 คะแนน |
คิ้วซ้าย (ด้านบน) |
5 คะแนน |
ริมฝีปากบน (ด้านล่าง) |
9 คะแนน |
คิ้วซ้าย (ด้านล่าง) |
5 คะแนน |
ริมฝีปากล่าง (ด้านบน) |
9 คะแนน |
คิ้วขวา (ด้านบน) |
5 คะแนน |
ริมฝีปากล่าง (ก้น) |
9 คะแนน |
คิ้วขวา (ด้านล่าง) |
5 คะแนน |
ดั้งจมูก |
2 คะแนน |
ตาซ้าย |
16 คะแนน |
จมูกด้านล่าง |
3 คะแนน |
ตาขวา |
16 คะแนน |
แก้มซ้าย (ตรงกลาง) |
1 คะแนน |
แก้มขวา (ตรงกลาง) |
1 คะแนน |
เมื่อคุณได้รูปทรงของใบหน้าทั้งหมดพร้อมกัน คุณจะได้อาร์เรย์ 133 จุด
ซึ่งแผนที่จะแสดงแนวโค้งดังที่แสดงด้านล่าง
ดัชนีเส้นโครงร่างของจุดสนใจ |
0-35 |
ใบหน้ารูปวงรี |
36-40 |
คิ้วซ้าย (ด้านบน) |
41-45 |
คิ้วซ้าย (ด้านล่าง) |
46-50 |
คิ้วขวา (ด้านบน) |
51-55 |
คิ้วขวา (ด้านล่าง) |
56-71 |
ตาซ้าย |
72-87 |
ตาขวา |
88-96 |
ริมฝีปากบน (ด้านล่าง) |
97-105 |
ริมฝีปากล่าง (ด้านบน) |
106-116 |
ริมฝีปากบน (ด้านบน) |
117-125 |
ริมฝีปากล่าง (ก้น) |
126, 127 |
ดั้งจมูก |
128-130 |
จมูกด้านล่าง (โปรดทราบว่าจุดศูนย์กลางอยู่ที่ดัชนี 128) |
131 |
แก้มซ้าย (ตรงกลาง) |
132 |
แก้มขวา (ตรงกลาง) |
การจำแนกประเภท
การจำแนกประเภทจะเป็นตัวกำหนดว่าใบหน้าของคุณมีลักษณะบางอย่างหรือไม่
ขณะนี้ ML Kit รองรับ 2 ประเภท ได้แก่ ลืมตาและยิ้ม
การจัดประเภทเป็นค่าที่แน่นอน เป็นตัวระบุถึงความเชื่อมั่น
ว่ามีลักษณะบนใบหน้านั้นๆ ตัวอย่างเช่น ค่า 0.7 ขึ้นไปสำหรับการจัดประเภทการยิ้มแสดงว่ามีแนวโน้มที่บุคคลนั้นกำลังยิ้ม
การแยกประเภททั้ง 2 รายการนี้อาศัยการตรวจจับจุดสังเกต
และโปรดทราบว่าการจัดประเภทแบบ "ตาโล่ง" และ "ยิ้ม" จะใช้ได้กับใบหน้าของใบหน้าเท่านั้น เช่น ใบหน้าที่มีมุม Y ออยเลอร์ Y ขนาดเล็ก (ระหว่าง -18 ถึง 18 องศา)
ขนาดใบหน้าขั้นต่ำ
ขนาดใบหน้าขั้นต่ำคือขนาดใบหน้าที่ต้องการ โดยแสดงเป็นอัตราส่วนความกว้างของศีรษะต่อความกว้างของรูปภาพ เช่น ค่า 0.1 หมายความว่าด้านที่เล็กที่สุดที่จะค้นหาคือประมาณ 10% ของความกว้างของรูปภาพที่ค้นหา
ขนาดใบหน้าขั้นต่ำคือประสิทธิภาพเทียบกับความคุ้มค่า การตั้งค่าขนาดขั้นต่ำให้เล็กลงจะทำให้ตัวตรวจจับหาใบหน้าที่เล็กลงได้ แต่การตรวจจับจะใช้เวลานานขึ้น การตั้งค่าให้ใหญ่ขึ้นอาจไม่รวมใบหน้าที่เล็กลงแต่จะทำงานได้เร็วขึ้น
ขนาดใบหน้าขั้นต่ำไม่ใช่ขนาดที่จำกัด ตัวตรวจจับอาจพบว่าใบหน้าเล็กกว่าที่ระบุไว้เล็กน้อย
ขั้นตอนถัดไป
ใช้การตรวจจับใบหน้าในแอป iOS หรือ Android โดยทำดังนี้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-04 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-09-04 UTC"],[[["\u003cp\u003eML Kit's face detection feature locates and analyzes human faces in images and videos, identifying position, size, orientation, and facial landmarks like eyes and nose.\u003c/p\u003e\n"],["\u003cp\u003eFace tracking in ML Kit follows faces across video frames, enabling the identification of the same person without using facial recognition.\u003c/p\u003e\n"],["\u003cp\u003eOptional features include landmark detection (identifying points like eyes, nose, mouth), contour detection (outlining facial features), and classification (detecting smiles or open eyes).\u003c/p\u003e\n"],["\u003cp\u003ePerformance can be adjusted by setting the minimum face size, balancing speed and accuracy of detection.\u003c/p\u003e\n"]]],[],null,["Face detection locates human faces in visual media such as digital images or\nvideo. When a face is detected it has an associated position, size, and\norientation; and it can be searched for landmarks such as the eyes and nose.\n\nHere are some of the terms that we use regarding the face detection feature\nof ML Kit:\n\n- **Face tracking** extends face detection to video sequences. Any face that\n appears in a video for any length of time can be tracked from frame to frame.\n This means a face detected in consecutive video frames can be identified as\n being the same person. Note that this isn't a form of *face recognition*; face\n tracking only makes inferences based on the position and motion of the faces in\n a video sequence.\n\n- A **landmark** is a point of interest within a face. The left eye, right eye,\n and base of the nose are all examples of landmarks. ML Kit provides the\n ability to find landmarks on a detected face.\n\n- A **contour** is a set of points that follow the shape of a facial feature.\n ML Kit provides the ability to find the contours of a face.\n\n- **Classification** determines whether a certain facial\n characteristic is present. For example, a face can be classified by\n whether its eyes are open or closed, or if the face is smiling or not.\n\nFace orientation\n\nThe following terms describe the angle a face is oriented with respect to the\ncamera:\n\n- **Euler X**: A face with a positive Euler X angle is facing upward.\n- **Euler Y**: A face with a positive Euler Y angle is looking to the right of the camera, or looking to the left if negative.\n- **Euler Z**: A face with a positive Euler Z angle is rotated counter-clockwise relative to the camera.\n\nML Kit doesn't report the Euler X, Euler Y or Euler Z angle of a detected face when\n`LANDMARK_MODE_NONE`, `CONTOUR_MODE_ALL`, `CLASSIFICATION_MODE_NONE` and\n`PERFORMANCE_MODE_FAST`are set together.\n\nLandmarks\n\nA landmark is a point of interest within a face. The left eye, right eye, and\nnose base are all examples of landmarks.\n\nML Kit detects faces without looking for landmarks.\nLandmark detection is an optional step that is disabled by default.\n\nThe following table summarizes all of the landmarks that can be detected given\nthe Euler Y angle of an associated face:\n\n| Euler Y angle | Detectable landmarks |\n|----------------------------|------------------------------------------------------------------------------------------------|\n| \\\u003c -36 degrees | left eye, left mouth, left ear, nose base, left cheek |\n| -36 degrees to -12 degrees | left mouth, nose base, bottom mouth, right eye, left eye, left cheek, left ear tip |\n| -12 degrees to 12 degrees | right eye, left eye, nose base, left cheek, right cheek, left mouth, right mouth, bottom mouth |\n| 12 degrees to 36 degrees | right mouth, nose base, bottom mouth, left eye, right eye, right cheek, right ear tip |\n| \\\u003e 36 degrees | right eye, right mouth, right ear, nose base, right cheek |\n\nEach detected landmark includes its associated position in the image.\n\nContours\n\nA contour is a set of points that represent the shape of a facial feature. The\nfollowing image illustrates how these points map to a face. Click the image to\nenlarge it:\n\n[](/static/ml-kit/vision/face-detection/images/face_contours.svg)\n\nEach feature contour that ML Kit detects is represented by a fixed number of\npoints:\n\n| Face oval | 36 points | Upper lip (top) | 11 points |\n| Left eyebrow (top) | 5 points | Upper lip (bottom) | 9 points |\n| Left eyebrow (bottom) | 5 points | Lower lip (top) | 9 points |\n| Right eyebrow (top) | 5 points | Lower lip (bottom) | 9 points |\n| Right eyebrow (bottom) | 5 points | Nose bridge | 2 points |\n| Left eye | 16 points | Nose bottom | 3 points |\n| Right eye | 16 points |\n| Left cheek (center) | 1 point |\n| Right cheek (center) | 1 points |\n|------------------------|-----------|--------------------|-----------|\n\nWhen you get all of a face's contours at once, you get an array of 133 points,\nwhich map to feature contours as shown below:\n\n| Indexes of feature contours ||\n|----------|----------------------------------------------------------|\n| 0-35 | Face oval |\n| 36-40 | Left eyebrow (top) |\n| 41-45 | Left eyebrow (bottom) |\n| 46-50 | Right eyebrow (top) |\n| 51-55 | Right eyebrow (bottom) |\n| 56-71 | Left eye |\n| 72-87 | Right eye |\n| 88-96 | Upper lip (bottom) |\n| 97-105 | Lower lip (top) |\n| 106-116 | Upper lip (top) |\n| 117-125 | Lower lip (bottom) |\n| 126, 127 | Nose bridge |\n| 128-130 | Nose bottom (note that the center point is at index 128) |\n| 131 | Left cheek (center) |\n| 132 | Right cheek (center) |\n\nClassification\n\nClassification determines whether a certain facial characteristic is present.\nML Kit currently supports two classifications: **eyes open** and **smiling**.\n\nClassification is a certainty value. It indicates the confidence\nthat a facial characteristic is present. For example, a value of 0.7 or more\nfor the smiling classification indicates that it's likely that a person is\nsmiling.\n\nBoth of these classifications rely upon landmark detection.\n\nAlso note that the classifications \"eyes open\" and \"smiling\" only work for\nfrontal faces, i.e., faces with a small Euler Y angle (between -18 and 18\ndegrees).\n\nMinimum Face Size\n\nThe minimum face size is the desired face size, expressed as the ratio of the width of\nthe head to the width of the image. For example, the value of 0.1 means that\nthe smallest face to search for is roughly 10% of the width of the image being\nsearched.\n\nThe minimum face size is a performance vs. accuracy trade-off: setting the\nminimum size smaller lets the detector find smaller faces but detection\nwill take longer; setting it larger might exclude smaller faces but\nwill run faster.\n\nThe minimum face size is not a hard limit; the detector may find faces slightly\nsmaller than specified.\n\nNext Steps\n\nUse face detection in your iOS or Android app:\n\n- [iOS](/ml-kit/vision/face-detection/ios)\n- [Android](/ml-kit/vision/face-detection/android)"]]