【发布时间】:2016-10-20 15:29:33
【问题描述】:
我正在尝试运行由Dlib 库提供的 face_landmark_detection.py 示例。
但是当我尝试通过 ubuntu 终端运行命令时出现错误:
Illegal instruction (core dumped)
我调试它,所以我知道这是因为这条线:
win=dlib.image_window()
我猜这行有问题
我正在通过这个命令运行代码:
./face_landmark_detection.py /home/abhishek/openCV/shape_predictor_68_face_landmarks.dat ../examples/faces
正如示例代码中所做的那样。 我的代码
import sys
import os
import dlib
import glob
from skimage import io
if len(sys.argv) != 3:
print(
"Give the path to the trained shape predictor model as the first "
"argument and then the directory containing the facial images.\n"
"For example, if you are in the python_examples folder then "
"execute this program by running:\n"
" ./face_landmark_detection.py shape_predictor_68_face_landmarks.dat ../examples/faces\n"
"You can download a trained facial shape predictor from:\n"
" http://sourceforge.net/projects/dclib/files/dlib/v18.10/shape_predictor_68_face_landmarks.dat.bz2")
exit()
predictor_path = sys.argv[1]
faces_folder_path = sys.argv[2]
print predictor_path
print faces_folder_path
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
win = dlib.image_window()
for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
print("Processing file: {}".format(f))
img = io.imread(f)
print "img",img
win.clear_overlay()
win.set_image(img)
# Ask the detector to find the bounding boxes of each face. The 1 in the
# second argument indicates that we should upsample the image 1 time. This
# will make everything bigger and allow us to detect more faces.
dets = detector(img, 1)
print("Number of faces detected: {}".format(len(dets)))
for k, d in enumerate(dets):
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
k, d.left(), d.top(), d.right(), d.bottom()))
# Get the landmarks/parts for the face in box d.
shape = predictor(img, d)
print("Part 0: {}, Part 1: {} ...".format(shape.part(0),
shape.part(1)))
# Draw the face landmarks on the screen.
win.add_overlay(shape)
win.add_overlay(dets)
dlib.hit_enter_to_continue()
【问题讨论】:
-
非法教学的常见原因有很多。该文件可能已作为文本而不是二进制文件下载,或者有人将文本编辑器带到可执行文件并将其保存为文本。可能是您使用不兼容的字长运行,例如带有 32 位模块的 64 位 python(反之亦然)。或者,您可以运行来自不同架构的可执行文件,例如 UNIX 平台上的 Windows 二进制文件,或 Intel 上的 Solaris (RISC)。检查您的安装。
-
至少对于可执行文件,如果您尝试为不同架构运行二进制文件,您宁愿获得
exec format error。illegal instruction也可以来自更微妙的东西,例如使用编译后的二进制文件在不支持此功能的旧处理器(例如,比用于 AVX 的 Sandy Bridge 旧)上使用较新处理器代(例如 AVX)的指令。 -
@cdarke,我已经检查了安装并再次完成了安装。我不认为有任何安装错误。我可能认为,从终端运行可能会导致错误,因为它不支持 GUI。你能告诉如何支持GUI。有些东西是代码无法处理的。
标签: python face-detection coredump dlib