code: def crop(
      image,
      pts,
      shift=0,
      scale=1.5,
      rotate=0,
      res_width=128,
      res_height=128,
  ):
      res = (res_width, res_height)
      idx1 = 0
      idx2 = 1
      # angle
      alpha = 0
      if (
          pts[idx2, 0] != -1
          and pts[idx2, 1] != -1
          and pts[idx1, 0] != -1
          and pts[idx1, 1] != -1
      ):
          alpha = (
              math.atan2(
                  pts[idx2, 1] - pts[idx1, 1],
                  pts[idx2, 0] - pts[idx1, 0],
              )
              * 180
              / math.pi
          )
      pts[pts == -1] = np.inf
      coord_min = np.min(pts, 0)
      pts[pts == np.inf] = -1
      coord_max = np.max(pts, 0)
      # coordinates of center point
      c = np.array(
          [
              coord_max[0] - (coord_max[0] - coord_min[0]) / 2,
              coord_max[1] - (coord_max[1] - coord_min[1]) / 2,
          ]
      )  # center
      max_wh = max(
          (coord_max[0] - coord_min[0]) / 2,
          (coord_max[1] - coord_min[1]) / 2,
      )
      # Shift the center point, rot add eyes angle
      c = c + shift * max_wh
      rotate = rotate + alpha
      M = cv2.getRotationMatrix2D(
          (c[0], c[1]), rotate, res[0] / (2 * max_wh * scale)
      )
      M[0, 2] = M[0, 2] - (c[0] - res[0] / 2.0)
      M[1, 2] = M[1, 2] - (c[1] - res[0] / 2.0)
      image_out = cv2.warpAffine(image, M, res)
      return image_out, M
  
file_path: PaddleHub/modules/image/face_detection/pyramidbox_lite_mobile_mask/data_feed.py
imports: import math
  import os
  import time
  from collections import OrderedDict
  import cv2
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: crop(image, pts, shift, scale, rotate, res_width, res_height) and returns: image_out,  M