如何修复"RuntimeError:无法打开shape_predictor_68_face_landmarks.dat"在使用Google Colab时? [英] How do I fix "RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat" while using google colab?

查看:1370
本文介绍了如何修复"RuntimeError:无法打开shape_predictor_68_face_landmarks.dat"在使用Google Colab时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Google Colaboratory 中编写以下Python代码并收到错误消息:

I am writing the following Python code in Google Colaboratory and get an error:

代码:

import cv2
import dlib

cap = cv2.VideoCapture(0)

hog_face_detector = dlib.get_frontal_face_detector()

dlib_facelandmark = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

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

faces = hog_face_detector(gray)
for face in faces:

    face_landmarks = dlib_facelandmark(gray, face)

    for n in range(0, 16):
        x = face_landmarks.part(n).x
        y = face_landmarks.part(n).y
        cv2.circle(frame, (x, y), 1, (0, 255, 255), 1)


cv2.imshow("Face Landmarks", frame)

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

错误:

RuntimeError跟踪(最近一次通话)在 ()6个hog_face_detector = dlib.get_frontal_face_detector()7---->8 dlib_facelandmark = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")910,则为True:

RuntimeError Traceback (most recent call last) in () 6 hog_face_detector = dlib.get_frontal_face_detector() 7 ----> 8 dlib_facelandmark = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") 9 10 while True:

RuntimeError:无法打开shape_predictor_68_face_landmarks.dat

RuntimeError: Unable to open shape_predictor_68_face_landmarks.dat

推荐答案

对我来说,解决类似问题的方法是下载Anaconda 3并按照此处的指导安装dlib:

For me what worked for a similar problem was downloading Anaconda 3 and installing dlib as guided here: https://learnopencv.com/install-dlib-on-windows/

我还将项目解释器更改为Anaconda(我使用PyCharm)

I also changed the project interpreter to Anaconda (I use PyCharm)

这篇关于如何修复"RuntimeError:无法打开shape_predictor_68_face_landmarks.dat"在使用Google Colab时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆