0

Here is the code.

import cv2
import mediapipe as mp

webcam=cv2.VideoCapture(0)
mp_face=mp.solutions.face_mesh
mp_drawing=mp.solutions.drawing_utils
with mp_face.FaceMesh(min_detection_confidence=0.5,min_tracking_confidence=0.5) as face_mesh:
    while True:
        control,frame=webcam.read()
        if control==False:
            break
        rgb=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
        result=face_mesh.process(rgb)
        if result.multi_face_landmarks:
            for face_landmarks in result.multi_face_landmarks:
                mp_drawing.draw_landmarks(frame,face_landmarks,mp_face.FACEMESH_TESSELATION)
        cv2.imshow("Test",frame)
        if cv2.waitKey(10)==27:
            break

What is data type of result at this line of code?

result = face_mesh.process(rgb)

What I tried:

Documentation says it returns

A NamedTuple object with a "detections" field that contains a list of the detected face location data.

But when I use debugger myself # print(type ( face_mesh.process(rgb) ) )

prints <class 'type'>

Upon further investigation using debugger says result has type of

<class 'mediapipe.python.solution_base.SolutionOutputs'>

So why does the documentation says it returns an object while the IDE says it returns a class?

0 Answers0