Reputation: 995
I am trying to run face_landmark_detection.py example sample which was provided by the Dlib
library.
But when i am trying to run the command via ubuntu terminal I am getting error:
Illegal instruction (core dumped)
I debug it so i get to know it is because of this line :
win=dlib.image_window()
I guess something is wrong with this line
I am running code via this command:
./face_landmark_detection.py /home/abhishek/openCV/shape_predictor_68_face_landmarks.dat ../examples/faces
As done in the sample code. my code
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()
Upvotes: 2
Views: 3281
Reputation: 782
I just ran into this and it was because the python module was being compiled with SSE4 instructions but my CPU only supports SSE2. Open tools/python/CMakeLists.txt and edit the line
set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
In my case I changed it to
set(USE_SSE2_INSTRUCTIONS ON CACHE BOOL "Use SSE2 instructions")
Upvotes: 1
Reputation: 2511
Looks like dlib can't create image window in your case. Possible reason of it - incorrect dlib installation. As Dlib's documentation describes (readme.txt), you should install it by running setup.py:
COMPILING DLIB Python API
Before you can run the Python example programs you must compile dlib. Type:
python setup.py install
or type
python setup.py install --yes USE_AVX_INSTRUCTIONS
if you have a CPU that supports AVX instructions, since this makes some
things run faster.
Also you will need libx11-dev installed (sudo apt-get install libx11-dev) before running setup.py
Check installation script messages to see any possible errors, and if you see them - update your question to describe situation
Upvotes: 2