Skip to content

Commit 26a7ebb

Browse files
committed
the landmarks_demo.py fails with an obscure error when no faces are detected in the input image. Added some error handling so that it's more transparent.
1 parent daaf645 commit 26a7ebb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/face/samples/landmarks_demo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
print("cascade not found")
1919
exit()
2020
faces = cascade.detectMultiScale(frame, 1.05, 3, cv.CASCADE_SCALE_IMAGE, (30, 30))
21-
ok, landmarks = facemark.fit(frame, faces=faces)
21+
if len(faces) == 0:
22+
print('no faces detected')
23+
landmarks = []
24+
else:
25+
ok, landmarks = facemark.fit(frame, faces=faces)
2226
cv.imshow("Image", frame)
2327
for marks in landmarks:
2428
couleur = (random.randint(0,255),

0 commit comments

Comments
 (0)