Example #1
0
def geometry_msgs_points_to_face_landmarks(geometry_msgs_points):
    points = dlib.points()
    [
        points.append(dlib.point(int(p.x), int(p.y)))
        for p in geometry_msgs_points
    ]
    return points
Example #2
0
def substitute_points(dlib_points, mtcnn_points):
    #face left, face right, nose, mouth left, mouth right
    SUBSTITUTE = [0, 16, 30, 48, 54]
    
    new_points = dlib.points()
    len_mtcnn = len(mtcnn_points) // 2

    for i in range(len_mtcnn):
        dlib_points[SUBSTITUTE[i]] = dlib.point(
            round(float(mtcnn_points[i])),
            round(float(mtcnn_points[i + len_mtcnn])))

    return dlib_points
Example #3
0
def test_points():
    ps = points()

    ps.resize(5)
    assert len(ps) == 5
    for i in range(5):
        assert ps[i].x == 0
        assert ps[i].y == 0

    ps.clear()
    assert len(ps) == 0

    ps.extend([point(1, 2), point(3, 4)])
    assert len(ps) == 2

    ser = pickle.dumps(ps, 2)
    deser = pickle.loads(ser)
    assert deser[0].x == 1
    assert deser[0].y == 2
    assert deser[1].x == 3
    assert deser[1].y == 4
Example #4
0
    image, cv2.COLOR_BGR2RGB), minsize, pnet, rnet, onet,
    threshold, factor)

print(str(path_to_image))
print(detected_faces)
left, top, right, bottom = get_points(detected_faces, 0)
face_box = dlib.rectangle(left, top, right, bottom)
#d = dlib.rectangle(1,2,3,4)
#print(str(path_to_image) + "----" + str(detected_faces[0]) + "----" + str(d))
# Get pose/landmarks of those faces
# Will be used as an input to the function that computes face encodings
# This allows the neural network to be able to produce similar numbers
#for faces of the same people, regardless of camera angle and/or face positioning in the image
shapes_faces = [shape_predictor(image, face_box)]

face_traits = dlib.points()
len_points = len(points) // 2
for i in range(len_points):
    face_traits.append(dlib.point( round(float(points[i])) ,
        round(float(points[i + len_points]))))
shapes_points = [dlib.full_object_detection(face_box, face_traits)]

#if ( str(path_to_image) == "pics/rakoruja.jpg"):
#print("\n\n--------------------------------------------")
#img = cv2.imread(path_to_image)
draw_facial_points(image, shapes_faces[0].parts(), 3)
cv2.imwrite(os.path.join("./", "OUTPUT-COLOURFUL" +
    ".jpg"), image)
cv2.waitKey(30)

for i in range(len(shapes_faces[0].parts())):