TypeError : 'list' object is not callable

Question:

i was working with face mesh module of opencv to detect my face
when i try to run it on my code editor it show
"landmarks = landmark_points(1).landmark" this list as not callable

import cv2
import mediapipe as mp

from cv2 import _registerMatType


cam = cv2.VideoCapture(0)

face_mesh = mp.solutions.face_mesh.FaceMesh()

while True: 

    _, frame = cam.read()

    rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    
    #to get face detected
    output = face_mesh.process(rgb_frame)
    landmark_points = output.multi_face_landmarks
    
    #to get coordinates of face 
    if landmark_points:
        landmarks = landmark_points(1).landmark
        for landmark in landmarks:
            x = landmark.x
            y = landmark.y
            print(x, y)

    #frame display
    cv2.imshow('face detection', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break

cam.release

cv2.destroyAllWindows()

the code work properly if we replace the coordinate section with "print(landmark_points)"
but i can not use the then result for my purpose, as i want it in (x,y) format

tried some sources but could not understand problem.
can some one provide solution with expanation?

Asked By: Rishabh Tiwari

||

Answers:

landmark_points is a list. landmark_points(1) attempts to "call" it like a function. Did you mean landmark_points[1]? That accesses an element in a list with index 1.

Note that landmark_points[1] is a second element, you probably want landmark_points[0] (first element)

Answered By: Yevhen Kuzmovych
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.