首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mediapipe,把地标分配给顶点?

Mediapipe,把地标分配给顶点?
EN

Stack Overflow用户
提问于 2021-09-13 18:29:39
回答 1查看 559关注 0票数 3

Here是mediapipe用于其面部网格模型的fbx格式的面部。它有468个顶点。Here是索引的可视化。

Here是对mediapipes面网格模型的描述。它输出地标位置。

我如何知道哪个地标属于哪个顶点?例如在搅拌机中。当我导入fbx face时,我如何才能获得与mediapipe face网格模型的地标相同的索引?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-16 05:28:24

使用fbx模型的搅拌机中的索引似乎与mediapipe face网格解决方案中提供的索引相同。这些指标与mediapipe canonical face model uv visualization中的指标相同。This answer提供了通过索引获取地标的示例。

需要启用Developer Extras。在编辑模式下,该选项显示在Viewport Overlays > Developer > Indices下,如下所示,以便在搅拌器中获取索引。获取索引的替代选项可以是found here

我已经展示了一个左眼地标索引的例子,因为它们出现在规范的脸部网格uv可视化中。

索引可视化

代码

基于的代码,https://google.github.io/mediapipe/solutions/face_mesh.html

代码语言:javascript
复制
import cv2
import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_drawing_styles = mp.solutions.drawing_styles
mp_face_mesh = mp.solutions.face_mesh

# For static images:

import glob
IMAGE_FILES = glob.glob('img.jpg')


drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)
with mp_face_mesh.FaceMesh(
    static_image_mode=True,
    max_num_faces=1,
    refine_landmarks=True,
    min_detection_confidence=0.5) as face_mesh:
  for idx, file in enumerate(IMAGE_FILES):
    image = cv2.imread(file)
    # Convert the BGR image to RGB before processing.
    results = face_mesh.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))

    # Print and draw face mesh landmarks on the image.
    if not results.multi_face_landmarks:
      continue
    annotated_image = image.copy()

    landmarks_list = [
        33, 7, 163, 144, 145, 153, 154, 155,
        133, 173, 157, 158, 159, 160, 161, 246
    ]

    for face_landmarks in results.multi_face_landmarks:
      #print('face_landmarks:', face_landmarks)

      print(len(face_landmarks.landmark))
    #   print(face_landmarks.landmark[7])

      for idx in landmarks_list:
        loc_x = int(face_landmarks.landmark[idx].x * image.shape[1])
        loc_y = int(face_landmarks.landmark[idx].y * image.shape[0])
        print(loc_x, loc_y)
        cv2.circle(annotated_image,(loc_x, loc_y), 2, (255,255,255), 2)

    cv2_imshow(annotated_image)

输出

演示笔记本

https://github.com/quickgrid/AI-Resources/blob/master/code-lab/computer_vision/Mediapipe_Python_Holistic_and_Face_Mesh.ipynb

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69167499

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档