          pad_t = 1 - box[1] if box[1] < 0 else 0
          pad_r = box[2] - width if box[2] > width else 0
          pad_b = box[3] - height if box[3] > height else 0
          logger.trace("Padding: (l: %s, t: %s, r: %s, b: %s)", pad_l, pad_t, pad_r, pad_b)
          retval = cv2.copyMakeBorder(image.copy(),
                                      pad_t,
                                      pad_b,
                                      pad_l,
                                      pad_r,
                                      cv2.BORDER_CONSTANT,
                                      value=(0, 0, 0))
          logger.trace("Padded shape: %s", retval.shape)
          return retval
  
      def predict(self, batch):
          """ Predict the 68 point landmarks """
          logger.trace("Predicting Landmarks")
          self.model.setInput(batch["feed"])
 
</s> remove         width, height = image.shape[:2]
 </s> add         height, width = image.shape[:2] </s> remove             # Pad the image if face is outside of boundaries
            image = self.pad_image(roi, image)
            face = image[roi[1]: roi[3], roi[0]: roi[2]]
 </s> add  </s> remove         # Shift the box if any points fall below zero
        if left < 0:
            shift_right = abs(left)
            right += shift_right
            left += shift_right
        if top < 0:
            shift_down = abs(top)
            bottom += shift_down
            top += shift_down

 </s> add  </s> remove         faces, batch["roi"] = self.align_image(batch)
 </s> add         faces, batch["roi"], batch["offsets"] = self.align_image(batch)
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
          pad_t = 1 - box[1] if box[1] < 0 else 0
          pad_r = box[2] - width if box[2] > width else 0
          pad_b = box[3] - height if box[3] > height else 0
          logger.trace("Padding: (l: %s, t: %s, r: %s, b: %s)", pad_l, pad_t, pad_r, pad_b)
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
        padded_image = cv2.copyMakeBorder(image.copy(),
                                          pad_t,
                                          pad_b,
                                          pad_l,
                                          pad_r,
                                          cv2.BORDER_CONSTANT,
                                          value=(0, 0, 0))
        offsets = (pad_l - pad_r, pad_t - pad_b)
        logger.trace("image_shape: %s, Padded shape: %s, box: %s, offsets: %s",
                     image.shape, padded_image.shape, box, offsets)
        return padded_image, offsets
  
      def predict(self, batch):
          """ Predict the 68 point landmarks """
          logger.trace("Predicting Landmarks")
          self.model.setInput(batch["feed"])
keep keep keep keep replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 bugfix: CV2-DNN aligner. Fix Assertion error when bounding box falls out of frame 
plugins/extract/align/cv2_dnn.py