0

So after a few weeks, I finally managed to get Dlib installed, and immediately ran into another problem.

I downloaded and ran their face landmark dector: http://dlib.net/face_landmark_detection.py.html and while the actual program works fine, when I try to run it on large images:

enter image description here

The images don't fit on my screen:

enter image description here

The code for the actual keymark extractor is here:

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)

And despite combing through the Dlib documentation, there's no mention of window size in ghe win.set_image() or the win.add_overlay() functions.

How would I make the window smaller?

Rich
  • 1,103
  • 1
  • 15
  • 36

3 Answers3

1

If you click on the image you can drag it around. Or hold ctrl and scroll the mouse wheel. That lets you zoom just like it does in many other programs.

Davis King
  • 4,731
  • 1
  • 25
  • 26
0

There are some methods as in dlib:

pyramid_down();
resize_image();

you can resize image and then show to window.

  • And this works in python? I don't see it in the docs: http://dlib.net/python/index.html – Rich Jun 16 '16 at 08:38
0

Since I can't comment now, you can resize the image as @Anuj Singh said in his answer and then pass it to window: 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)

I am not sure if this method was add in python3 or not since the original question asks about python2.7.