【问题标题】:Working with large (over 2000x2000) images in Dlib, and they don't fit in my screen在 Dlib 中处理大(超过 2000x2000)图像,它们不适合我的屏幕
【发布时间】:2016-09-26 09:29:41
【问题描述】:

几周后,我终于成功安装了 Dlib,但马上又遇到了另一个问题。

我下载并运行了他们的面部标志性检测器:http://dlib.net/face_landmark_detection.py.html,虽然实际程序运行良好,但当我尝试在大图像上运行它时:

图片不适合我的屏幕:

实际keymark提取器的代码在这里:

win = dlib.image_window()

for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
print("Processing file: {}".format(f))
    img = io.imread(f)

win.clear_overlay()
win.set_image(img)

# Ask the detector to find the bounding boxes of each face. The 1 in the
# second argument indicates that we should upsample the image 1 time. This
# will make everything bigger and allow us to detect more faces.
dets = detector(img, 1)
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("Part 0: {}, Part 1: {} ...".format(shape.part(0),
                                              shape.part(1)))
    # Draw the face landmarks on the screen.
    win.add_overlay(shape)

尽管梳理了 Dlib 文档,但在 ghe win.set_image() 或 win.add_overlay() 函数中没有提及窗口大小。

如何让窗口变小?

【问题讨论】:

    标签: python image python-2.7 dlib keypoint


    【解决方案1】:

    由于我现在无法发表评论,您可以按照@Anuj Singh 在他的回答中所说的调整图像大小,然后将其传递给窗口:http://dlib.net/python/index.html#dlib.resize_image

    img = dlib.resize_image(img, 600, 400)  # if you want to resize to 600x400 px
    win.set_image(img)
    

    我不确定这个方法是否被添加到 python3 中,因为最初的问题是关于 python2.7。

    【讨论】:

      【解决方案2】:

      dlib中有一些方法:

      pyramid_down();
      resize_image();
      

      您可以调整图像大小,然后显示到窗口。

      【讨论】:

      【解决方案3】:

      如果您单击图像,您可以拖动它。或者按住 ctrl 并滚动鼠标滚轮。这让您可以像在许多其他程序中一样进行缩放。

      【讨论】:

      • 不,我知道我可以移动它。我想改变实际的图像大小。
      • 所以使用鼠标滚轮缩小
      • 我没有鼠标滚轮。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多