title: How to get points coordinate position in the face landmark detection program of dlib?
body: <p>There is one example python program in dlib to detect the face landmark position.
  <a href="http://dlib.net/face_landmark_detection.py.html" rel="noreferrer">face_landmark_detection.py</a></p>
  
  <p>This program detect the face feature and denote the landmarks with dots and lines in original photo.</p>
  
  <p>I wonder if it is possible to obtain each points' coordinate position. Like a(10, 25). 'a' denotes corner of the mouth.</p>
  
  <p>After slightly modifying the program to process one picture at one time, I try to print out the value of dets and shape without success. </p>
  
  <pre><code>&gt;&gt;&gt;print(dets)
  &lt;dlib.dlib.rectangles object at 0x7f3eb74bf950&gt;
  &gt;&gt;&gt;print(dets[0])
  [(1005, 563) (1129, 687)]
  </code></pre>
  
  <p>The arguments to denote face landmark points and the datatype of arguments still remain unknown.
  And here is the simplified code</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>---------------------------update on 3.10.2016---------------------------</p>
  
  <p>Today, I remember the help() method in python and have a trial with it.</p>
  
  <pre><code>&gt;&gt;&gt;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.
  </code></pre>
  
  <p>In the original code, variable <code>shape</code> is the output of predictor method.</p>
  
  <pre><code>&gt;&gt;&gt;help(shape)
  </code></pre>
  
  <p>The description of shape</p>
  
  <pre><code>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.
   |  
   |  ----------------------------------------------------------------------
  </code></pre>
  
  <p>It seems that variable <code>shape</code> is related with points coordinate position.</p>
  
  <pre><code>&gt;&gt;&gt;print(shape.num_parts)
  68
  &gt;&gt;&gt;print(shape.rect)
  [(1005, 563) (1129, 687)]
  </code></pre>
  
  <p>I assume that there are 68 denoted face landmark points.</p>
  
  <pre><code>&gt;&gt;&gt; print(shape.part(68))
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  IndexError: Index out of range
  &gt;&gt;&gt; print(shape.part(65))
  (1072, 645)
  &gt;&gt;&gt; print(shape.part(66))
  (1065, 647)
  &gt;&gt;&gt; print(shape.part(67))
  (1059, 646)
  </code></pre>
  
  <p>If it is true. The remained problem is that which part is responding to which face landmark point.</p>