如何在Dlib中保存已经显示的图像?

2024-04-20 14:14:07 发布

您现在位置:Python中文网/ 问答频道 /正文

运行代码之后

import dlib
from skimage.io import imsave, imread

sp = dlib.shape_predictor('shape_predictor_68_face_landmarks.dat')
facerec = dlib.face_recognition_model_v1('dlib_face_recognition_resnet_model_v1.dat')
detector = dlib.get_frontal_face_detector()

img = io.imread('foto.jpg')
win1 = dlib.image_window()
win1.clear_overlay()
win1.set_image(img)

dets = detector(img, 1)
for k, d in enumerate(dets):
    print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
        k, d.left(), d.top(), d.right(), d.bottom()))
    shape = sp(img, d)
    win1.clear_overlay()
    win1.add_overlay(d)

我在一个单独的窗口里有一张画着人脸标志的图片。你知道吗

如何将窗口中的图像保存到文件中?你知道吗

我被试过这样做

imsave('file.jpg',shape)

但没有成功。你知道吗


Tags: ioimportimgdetectorpredictorspdatface