title: Face aligment check with DLIB
body: <p>I am just wondering is it possible to detect is the face aligned correctly, straight to the camera with DLIB and OpenCV?</p>
  
  <p><a href="https://i.stack.imgur.com/gwfMX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gwfMX.png" alt="enter image description here"></a></p>
  
  <p>I tried this code to detect shape and get the points of face:</p>
  
  <p><a href="https://i.stack.imgur.com/OBgDf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OBgDf.png" alt="enter image description here"></a></p>
  
  <pre><code>detector = dlib.get_frontal_face_detector()
  predictor = dlib.shape_predictor(args["shape_predictor"])
  
  vs = VideoStream(0).start()
  
      while True:
          # grab the frame from the threaded video stream, resize it to
          # have a maximum width of 400 pixels, and convert it to
          # grayscale
          frame = vs.read()
          frame = imutils.resize(frame, width=400)
          gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  
          # detect faces in the grayscale frame
          rects = detector(gray, 0)
  
          # loop over the face detections
          for rect in rects:
              # determine the facial landmarks for the face region, then
              # convert the facial landmark (x, y)-coordinates to a NumPy
              # array
              shape = predictor(gray, rect)
              shape = face_utils.shape_to_np(shape)
  
              # loop over the (x, y)-coordinates for the facial landmarks
              # and draw them on the image
              for (x, y) in shape:
                  print x,y
                  cv2.circle(frame, (x, y), 1, (0, 0, 255), -1)
              cv2.putText(frame, "Aptiktas veidas", (10, 30),
                  cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
  
          # show the frame
          cv2.imshow("Frame", frame)
          key = cv2.waitKey(1) &amp; 0xFF
  </code></pre>