【问题标题】:Mediapipe's "multi_hand_landmarks" not workingMediapipe 的“multi_hand_landmarks”不起作用
【发布时间】:2021-08-05 07:17:57
【问题描述】:

我是第一次尝试 opencv 和 handtracking。 我正在按照“Mediapipe”官方网站上的逐步代码进行操作。 但是每当我尝试写“results.multi_hand_landmarks”时,PyCharm 都会报错说Unresolved Attribute Reference "multi_hand_landmarks" for class "NamedTuple"

你能帮帮我吗?

【问题讨论】:

    标签: python tracking mediapipe


    【解决方案1】:
    import mediapipe
    import cv2
    import null as null
    
    drawingModule = mediapipe.solutions.drawing_utils
    handsModule = mediapipe.solutions.hands
    
    capture = cv2.VideoCapture(0)
    
    with handsModule.Hands(static_image_mode=False, min_detection_confidence=0.7, min_tracking_confidence=0.7,max_num_hands=2) as hands:
            while (True):
                ret, frame = capture.read()
                results = hands.process(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
                if results.multi_hand_landmarks:
                    for handLandmarks in results.multi_hand_landmarks:
                        drawingModule.draw_landmarks(frame, handLandmarks, handsModule.HAND_CONNECTIONS)
                cv2.imshow('Test hand', frame)
                if cv2.waitKey(1) == 27:
                    break
    cv2.destroyAllWindows()
    capture.release() here
    

    当您将鼠标悬停在与您相同的行上但代码运行时,此代码也会显示相同的错误。可能是 PyCharm 和 Mediapipe 库的错误。

    在源代码中:

    输出=['multi_hand_landmarks', 'multi_handedness'])

    https://github.com/google/mediapipe/blob/710fb3de58dc10b7bc75f9cb758300c9016a5e4f/mediapipe/python/solutions/hands.py#L125

    【讨论】:

      猜你喜欢
      • 2022-06-15
      • 2022-12-04
      • 1970-01-01
      • 2021-07-30
      • 2021-03-11
      • 2022-11-22
      • 2021-05-09
      • 2022-06-14
      • 2021-12-16
      相关资源
      最近更新 更多