coneypo / Dlib_face_recognition_from_camera

Detect and recognize the faces from camera / 调用摄像头进行人脸识别,支持多张人脸同时识别
http://www.cnblogs.com/AdaminXie/p/9010298.html
MIT License
2.07k stars 572 forks source link

运行get_features_into_CSV.py时报错 #3

Closed EstellaCheng closed 6 years ago

EstellaCheng commented 6 years ago

我clone代码到本地后,将get_from_camera里的照片清空,然后修改路径后,运行get_faces_from_camera后得到自己的数据集。然后把default_person.csv也删除了,再运行get_features_into_CSV.py,结果报错如下: Traceback (most recent call last):

File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 76, in write_into_csv(path_pics, path_csv + "default_person.csv") File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 67, in write_into_csv features_128d = return_128d_features(path_pics + dir_pics[i]) File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 43, in return_128d_features face_descriptor = facerec.compute_face_descriptor(img_gray, shape) RuntimeError: The full_object_detection must use the iBUG 300W 68 point face landmark style.

Process finished with exit code 1 我后来把图像换成博主原来的图像,再次运行还是报这个错。。。请博主赐教。

coneypo commented 6 years ago

Hi,

应该是图像文件读写格式有问题, 用你的 测试图片 单独跑下 get_128d_features() 看有没有问题

返回单张图像的128D特征

def get_128d_features(img_gray): dets = detector(img_gray, 1) if len(dets) != 0: shape = predictor(img_gray, dets[0]) face_descriptor = facerec.compute_face_descriptor(img_gray, shape) else: face_descriptor = 0 return face_descriptor

get_128d_features("D:/test/test.jpg")

方便的话把你更改的源码贴给我下,应该不会有问题;

Best regrads

------------------ 原始邮件 ------------------ 发件人: "EstellaCheng"notifications@github.com; 发送时间: 2018年7月26日(星期四) 中午11:20 收件人: "coneypo/Dlib_face_recognition_from_camera"Dlib_face_recognition_from_camera@noreply.github.com; 抄送: "Subscribed"subscribed@noreply.github.com; 主题: [coneypo/Dlib_face_recognition_from_camera] 运行get_features_into_CSV.py时报错 (#3)

我clone代码到本地后,将get_from_camera里的照片清空,然后修改路径后,运行get_faces_from_camera后得到自己的数据集。然后把default_person.csv也删除了,再运行get_features_into_CSV.py,结果报错如下: Traceback (most recent call last):

File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 76, in write_into_csv(path_pics, path_csv + "default_person.csv") File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 67, in write_into_csv features_128d = return_128d_features(path_pics + dir_pics[i]) File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/get_features_into_CSV.py", line 43, in return_128d_features face_descriptor = facerec.compute_face_descriptor(img_gray, shape) RuntimeError: The full_object_detection must use the iBUG 300W 68 point face landmark style.

Process finished with exit code 1 我后来把图像换成博主原来的图像,再次运行还是报这个错。。。请博主赐教。

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

EstellaCheng commented 6 years ago

我单独运行了get_128d_features(),出现了问题。报错如下: Traceback (most recent call last): File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/test.py", line 24, in get_128d_features("D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/img_face_1.jpg") File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/test.py", line 15, in get_128d_features dets = detector(img_gray, 1) RuntimeError: Unsupported image type, must be 8bit gray or RGB image.

以下是我修改源码的地方: 在get_faces_from_camera.py里面修改了存储路径。

保存

line 28 path_save = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/"

在get_features_into_CSV.py里面也是修改了路径,共三处: line 18 path_pics = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/" line 19 path_csv = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/csvs/"

line 78 path_csv_rd = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/csvs/default_person.csv"

谢谢博主抽空帮我解决问题啦!

coneypo commented 6 years ago

Hi

不好意思刚下班

我觉得可能是你修改的时候误删了某一行,比如刚才发给你的那个 return_128d_features 函数,那样出错是因为传给他的图像格式不对,我觉得你可以check一下源码,类似于这种地方:

img=io.imread(path_img),看它传过去的是 文件路径 / img_gray 灰度图片 / RGB 通道图片 / HSV 通道图片 /.. from skimage import io

detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat') facerec = dlib.face_recognition_model_v1("dlib_face_recognition_resnet_model_v1.dat")

img_gray = io.imread(img_path) img_gray = cv2.cvtColor(img_gray, cv2.COLOR_BGR2RGB) dets = detector(img_gray, 1) if len(dets) != 0: shape = predictor(img_gray, dets[0]) face_descriptor = facerec.compute_face_descriptor(img_gray, shape) else: face_descriptor = 0

print(face_descriptor)

不行的话麻烦尝试下重新下载下 源码, link: https://github.com/coneypo/Dlib_face_recognition_from_camera/blob/master/get_features_into_CSV.py

------------------ 原始邮件 ------------------ 发件人: "EstellaCheng"notifications@github.com; 发送时间: 2018年7月26日(星期四) 下午2:47 收件人: "coneypo/Dlib_face_recognition_from_camera"Dlib_face_recognition_from_camera@noreply.github.com; 抄送: "coneypo"coneypo@gmail.com; "Comment"comment@noreply.github.com; 主题: Re: [coneypo/Dlib_face_recognition_from_camera] 运行get_features_into_CSV.py时报错 (#3)

我单独运行了get_128d_features(),出现了问题。报错如下: Traceback (most recent call last): File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/test.py", line 24, in get_128d_features("D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/img_face_1.jpg") File "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/test.py", line 15, in get_128d_features dets = detector(img_gray, 1) RuntimeError: Unsupported image type, must be 8bit gray or RGB image.

以下是我修改源码的地方: 在get_faces_from_camera.py里面修改了存储路径。

保存

line 28 path_save = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/"

在get_features_into_CSV.py里面也是修改了路径,共三处: line 18 path_pics = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/get_from_camera/" line 19 path_csv = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/csvs/"

line 78 path_csv_rd = "D:/360Downloads/JetBrains/Dlib_face_recognition_from_camera-master/data/csvs/default_person.csv"

谢谢博主抽空帮我解决问题啦!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

EstellaCheng commented 6 years ago

真是十分感谢博主啦。下了班还要帮我解决问题。。可是,,我把整个项目重新下载了一遍,就改了get_features_into_CSV.py里面的路径,运行起来还是会有哪个问题。。。。呜呜呜呜~~~天要灭我

coneypo commented 6 years ago

你好,请 clone 最新的代码,这个 issue 应该不会复现了; 如果没问题请 close 下,谢谢;