dlib에 얼굴 표식 위치를 감지하는 python 프로그램의 한 가지 예가 있습니다. face_landmark_detection.pydlib의 얼굴 표식 탐지 프로그램에서 포인트 좌표를 얻는 방법은 무엇입니까?
이 프로그램은 얼굴 특징을 감지하고 원래 사진에 점과 줄이있는 표식을 나타냅니다.
각 포인트의 좌표 위치를 얻을 수 있는지 궁금합니다. a (10, 25)처럼. 'a'는 입가를 나타냅니다.
한 번에 한 장의 사진을 처리하도록 프로그램을 약간 수정 한 후에 나는 dets 및 shape의 값을 성공없이 인쇄하려고합니다.
>>>print(dets)
<dlib.dlib.rectangles object at 0x7f3eb74bf950>
>>>print(dets[0])
[(1005, 563) (1129, 687)]
얼굴 표식 점과 인수의 데이터 유형을 나타내는 인수는 아직 알 수 없습니다. 그리고 여기가 2016년 3월 10일에 갱신 단순화 된 코드
import dlib
from skimage import io
#shape_predictor_68_face_landmarks.dat is the train dataset in the same directory
predictor_path = "shape_predictor_68_face_landmarks.dat"
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
win = dlib.image_window()
#FDT.jpg is the picture file to be processed in the same directory
img = io.imread("FDT.jpg")
win.set_image(img)
dets = detector(img)
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(shape)
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()
---------------------------입니다 ---- -----------------------
오늘 저는 파이썬에서 help() 메소드를 기억하고 그것에 대해 시험해 봅니다. shape
변수 일본어 코드에서
>>>help(predictor)
Help on shape_predictor in module dlib.dlib object:
class shape_predictor(Boost.Python.instance)
| This object is a tool that takes in an image region containing
some object and outputs a set of point locations that define the pose
of the object. The classic example of this is human face pose
prediction, where you take an image of a human face as input and are
expected to identify the locations of important facial landmarks such
as the corners of the mouth and eyes, tip of the nose, and so forth.
은 예측 방법의 출력이다.
>>>help(shape)
형상의 설명
class full_object_detection(Boost.Python.instance)
| This object represents the location of an object in an image along
with the positions of each of its constituent parts.
----------------------------------------------------------------------
| Data descriptors defined here:
|
| num_parts
| The number of parts of the object.
|
| rect
| The bounding box of the parts.
|
| ----------------------------------------------------------------------
가변 shape
이 위치 좌표 점과 관련된 것으로 보인다.
>>>print(shape.num_parts)
68
>>>print(shape.rect)
[(1005, 563) (1129, 687)]
나는 68 개의 얼굴 표식 점이 있다고 가정합니다.
>>> print(shape.part(68))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: Index out of range
>>> print(shape.part(65))
(1072, 645)
>>> print(shape.part(66))
(1065, 647)
>>> print(shape.part(67))
(1059, 646)
사실입니까? 남아있는 문제는 어느 부분이 어떤 얼굴 표식 점에 응답하고 있는지입니다.
당신은 포인트를 찾아 이미지에 숫자를 그릴 수 있습니다. 또는 당신은 여기에서 볼 수있다 https://matthewearl.github.io/2015/07/28/switching-eds-with-python/ – Evgeniy
와우, 그것은 좋은 생각이다. –
여기를 확인하세요, http://www.pyimagesearch.com/2017/04/03/facial-landmarks-dlib-opencv-python/ – saurabheights