Search code examples
pythonmediapipe

mediapipe.mp_holistic 'module' object is not callable


def PoseEstimation(frame,win_name):
    
    with mp_holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5) as holistic

        frame = cv.cvtColor(frame, cv.COLOR_BGR2RGB)
        results = holistic.process(frame)
        frame = cv.cvtColor(frame, cv.COLOR_RGB2BGR)

        # 2. Right hand
        mp_drawing.draw_landmarks(frame, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS,
                                 mp_drawing.DrawingSpec(color=(80,22,10), thickness=2, circle_radius=4),
                                 mp_drawing.DrawingSpec(color=(80,44,121), thickness=2, circle_radius=2)
                                 )
cv.imshow(win_name, frame)

My code is here

The Error is
with mp_holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5) as holistic: TypeError: 'module' object is not callable

What should i do so that i can use the module


Solution

  • You are using the mp.solutions.holistic as function instead of module. I think, somewhere in your code, you have:

    mp_holistic = mp.solutions.holistic
    

    Considering your snippet, I think you want to use the holistic call.

    Consequently you have to change your:

    with mp_holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5) as holistic:
    

    with

    with mp_holistic.Holistic(min_detection_confidence=0.5,min_tracking_confidence=0.5) as holistic: