简体   繁体   English

预测器出错 = dlib.shape_predictor(“shape_predictor_68_face_landmarks.dat”) RuntimeError:

[英]Having error in predictor = dlib.shape_predictor(“shape_predictor_68_face_landmarks.dat”) RuntimeError:

I'm keep running with error in line 8.我在第 8 行继续运行错误。

predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") RuntimeError: Unable to open shape_predictor_68_face_landmarks.da

I downloaded the files I tried to add the files to working directory but PyCharm doesn't let me drag and drop anything.我下载了我试图将文件添加到工作目录的文件,但是 PyCharm 不允许我拖放任何东西。

import cv2
import numpy as np
import dlib

cap = cv2.VideoCapture(0)

detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

def midpoint(p1 ,p2):
    return int((p1.x + p2.x)/2), int((p1.y + p2.y)/2)

while True:
    _, frame = cap.read()
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = detector(gray)
    for face in faces:
        #x, y = face.left(), face.top()
        #x1, y1 = face.right(), face.bottom()
        #cv2.rectangle(frame, (x, y), (x1, y1), (0, 255, 0), 2)

        landmarks = predictor(gray, face)
        left_point = (landmarks.part(36).x, landmarks.part(36).y)
        right_point = (landmarks.part(39).x, landmarks.part(39).y)
        center_top = midpoint(landmarks.part(37), landmarks.part(38))
        center_bottom = midpoint(landmarks.part(41), landmarks.part(40))

        hor_line = cv2.line(frame, left_point, right_point, (0, 255, 0), 2)
        ver_line = cv2.line(frame, center_top, center_bottom, (0, 255, 0), 2)

    cv2.imshow("Frame", frame)

    key = cv2.waitKey(1)
    if key == 27:
        break

cap.release()
cv2.destroyAllWindows()

Solve the problem.解决这个问题。 I went in my Mac open pycharm install dlib and at first I had the same problem.我进入我的 Mac 打开 pycharm 安装 dlib,起初我遇到了同样的问题。 the type in google shape_predictor_68_face_landmarks.dat. google shape_predictor_68_face_landmarks.dat 中的类型。 search different option the best source: https://github.com/davisking/dlib-models/blob/master/shape_predictor_68_face_landmarks.dat.bz2 download the file and I dropped the file in sam搜索不同选项的最佳来源: https://github.com/davisking/dlib-models/blob/master/shape_predictor_68_face_landmarks.dat.bz2下载文件,我将文件放入 sam

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PyInstaller:如何使用 dlib.shape_predictor 调用“shape_predictor_68_face_landmarks.dat”文件,同时使用“二进制文件”导入它? - PyInstaller: How to call "shape_predictor_68_face_landmarks.dat" file with dlib.shape_predictor, while imported it with 'binaries'? RuntimeError:无法打开 shape_predictor_68_face_landmarks.dat? - RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat? RuntimeError:无法打开 shape_predictor_68_face_landmarks.dat - RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat 在 macos 中使用 pyinstaller 进行转换期间包含“shape_predictor_68_face_landmarks.dat”时出错 - error in including "shape_predictor_68_face_landmarks.dat" during conversion using pyinstaller in macos 如何在使用 google colab 时修复“RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat”? - How do I fix "RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat" while using google colab? dlib.shape_predictor:反序列化 int 类型的对象 - dlib.shape_predictor: deserializing object of type int 运行时错误:无法打开 shape_predictor_68_face_landmark.dat(无法执行脚本 main) - Runtime Error: Unable to open shape_predictor_68_face_landmark.dat (Fail to execute script main) 如何训练形状预测器dlib - How to train shape predictor dlib dlib 形状预测器模型的参数 - Parameters of dlib shape predictor model 为什么在构建可执行文件时形状预测器模型“shape_predictor_68 ...”没有包含在 face_recognition 库中? - Why doesn't the shape predictor model "shape_predictor_68..." get included along the face_recognition library when building the executable?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM