text: 
  import cv2
  import numpy as np
  
  
  def shape_to_np(shape, dtype="int"):
      coords = np.zeros((68, 2), dtype=dtype)
      for i in range(0, 68):
          coords[i] = (shape.part(i).x, shape.part(i).y)
      return coords
  
  def eye_on_mask(mask, side, shape):
      points = [shape[i] for i in side]
      points = np.array(points, dtype=np.int32)
      mask = cv2.fillConvexPoly(mask, points, 255)
      l = points[0][0]
      t = (points[1][1]+points[2][1])//2
      r = points[3][0]
      b = (points[4][1]+points[5][1])//2
      return mask, [l, t, r, b]
  
  def find_eyeball_position(end_points, cx, cy):
      x_ratio = (end_points[0] - cx)/(cx - end_points[2])
      y_ratio = (cy - end_points[1])/(end_points[3] - cy)
      if x_ratio > 3:
          return 1
      elif x_ratio < 0.33:
          return 2
      elif y_ratio < 0.33:
          return 3
      else:
          return 0
  
  def contouring(thresh, mid, img, end_points, right=False):
      cnts, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:]
      try:
          cnt = max(cnts, key=cv2.contourArea)
          M = cv2.moments(cnt)
          cx = int(M['m10']/M['m00'])
          cy = int(M['m01']/M['m00'])
          if right:
              cx += mid
          cv2.circle(img, (cx, cy), 4, (0, 0, 255), 2)
          return find_eyeball_position(end_points, cx, cy)
      except:
          pass
  
  def process_thresh(thresh):
      thresh = cv2.erode(thresh, None, iterations=2)
      thresh = cv2.dilate(thresh, None, iterations=4)
      thresh = cv2.medianBlur(thresh, 3)
      thresh = cv2.bitwise_not(thresh)
      return thresh
  
  def print_eye_pos(left, right):
      if left == right:
          if left == 1:
              print('Looking left,student is cheating')
          elif left == 2:
              print('Looking right,student is cheating')
          elif left == 3:
              print('Looking up,student is cheating')
  
  def nothing(x):
      pass
  