php 获取图片脸部坐标,如何获取dlib的脸部标志点检测程序中的点坐标位置?

该程序检测脸部特征并用原始照片中的点和线表示地标。

我想知道是否有可能获得每个点的坐标位置。像(10,25)一样。 'a'表示嘴角。

稍微修改程序一次处理一张图片后,我尝试打印出dets和shape的值而没有成功。

>>>print(dets)

>>>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()

---------------------------更新---- -----------------------

今天,我记得python中的help()方法,并试用了它。

>>>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.

在原始代码中,变量shape是预测方法的输出。

>>>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 "", line 1, in

IndexError: Index out of range

>>> print(shape.part(65))

(1072, 645)

>>> print(shape.part(66))

(1065, 647)

>>> print(shape.part(67))

(1059, 646)

如果它是真的。剩下的问题是哪个部分响应哪个人脸标志点。

+0

您可以检测点并在图像上绘制其编号。或者你可以看看这里https://matthewearl.github.io/2015/07/28/switching-eds-with-python/ –

+0

哇,这是一个好主意。 –

+1

请点击这里,http://www.pyimagesearch.com/2017/04/03/facial-landmarks-dlib-opencv-python/ –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值