首页 > 解决方案 > TypeError: Can't display face landmarks with OpenCV using camera

问题描述

当我突然收到此错误时,我正在关注 OpenCV 的教程:

TypeError: __call__(): incompatible function arguments. The following argument types are supported:
1. (self: _dlib_pybind11.shape_predictor, image: array, box: _dlib_pybind11.rectangle) -> _dlib_pybind11.full_object_detection

我试图使用 module.py 中的代码来绘制这个面部标志: 在此处输入图像描述

predictor = dlib.shape_predictor("Predictor/shape_predictor_68_face_landmarks.dat")

def faceLandmarkDetector(image, gray, face, Draw=True):
    landmarks = predictor(gray, face)
    pointList = []

    for n in range(0, 68):
        point = (landmarks.part(n).x, landmarks.part(n).y)
        pointList.append(point)

        if Draw == True:
            cv.circle(image, point, 3, ORANGE, 1)
    return image, pointList

我在 main.py 上使用此代码调用它:

image, PointList = m.faceLandmarkDetector(frame, grayFrame, face)

我不知道这个错误是什么意思,我试图查看我的参数,但我无法识别我的错误。我需要一些帮助,我已经尝试了一些解决类似问题的方法,但它们不起作用。我的相机很好,我检查了我的模块版本。

我遵循的教程在这里,在 12 分钟标记处是我开始遇到问题的地方。

标签: pythonpython-3.xopencvcv2dlib

解决方案


推荐阅读