1
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

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Fish Ung
  • 17
  • 8
  • 1
    Does this answer your question? [TypeError: 'module' object is not callable](https://stackoverflow.com/questions/4534438/typeerror-module-object-is-not-callable) – Christoph Rackwitz Aug 02 '22 at 08:20

1 Answers1

0

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:
Julien Sorin
  • 703
  • 2
  • 12
  • Yeah, i think this solves my bug. I wanna ask why this makes a difference. when i use the original line of code in main function, it works. when i use it in subfunctions, it fail with the above-mentioned error – Fish Ung Aug 02 '22 at 08:18
  • you still don't understand the difference. the code is different, not the place it's used. – Christoph Rackwitz Aug 02 '22 at 08:21