// Copyright 2019 The MediaPipe Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto2";

package mediapipe.autoflip;

import "mediapipe/framework/calculator.proto";

message FaceBoxAdjusterCalculatorOptions {
  extend mediapipe.CalculatorOptions {
    optional FaceBoxAdjusterCalculatorOptions ext = 347462240;
  }

  // When faces are detected in a given frame, we check these number of frames
  // in the past. We include only those faces in auto framing that have been
  // seen in this past history. This helps reduce False Positives and also
  // handles some of the edge cases. Setting the value to 0 disables the
  // feature.
  optional int32 num_frame_history = 1 [default = 0];

  // IOU threshold for matching detected faces with the faces in the frame
  // history buffer.
  optional float iou_threshold = 2 [default = 0.2];

  // If true, the face boxes are adjusted based on their face pose. This is done
  // to correct for extreme poses that can cause the detected face boxes to be
  // either too big or too small.
  optional bool adjust_for_pose = 3 [default = true];

  // There are DEPRECATED fields. Do not use.
  optional float box_area_change_per_up_tilt_degree = 4 [deprecated = true];
  optional float box_area_change_per_down_tilt_degree = 5 [deprecated = true];

  // The ratios of the face-pose corrected IPD to the face bounding box's width
  // and height respectively.
  optional float ipd_face_box_width_ratio = 6 [default = 0.5566];
  optional float ipd_face_box_height_ratio = 7 [default = 0.3131];

  // The max look up angle before considering the eye distance unstable.
  optional float max_head_tilt_angle_deg = 8 [default = 5.0];
  // The min look up angle (i.e. looking down) before considering the eye
  // distance unstable.
  optional float min_head_tilt_angle_deg = 10 [default = -18.0];
  // The max look right angle before considering the eye distance unstable.
  optional float max_head_pan_angle_deg = 11 [default = 25.0];
  // The min look right angle (i.e. looking left) before considering the eye
  // distance unstable.
  optional float min_head_pan_angle_deg = 12 [default = -25.0];

  // Update rate for motion history, valid values [0.0, 1.0].
  optional float motion_history_alpha = 13 [default = 0.5];

  // Max value of head motion (max of current or history) to be considered still
  // stable.
  optional float head_motion_threshold = 14 [default = 360.0];

  // The max amount of time to use an old eye distance when the face look angle
  // is unstable.
  optional int32 max_facesize_history_us = 9 [default = 300000000];

  // Scale factor of face width to shift based on pan look angle.
  optional float pan_position_shift_scale = 15
      [default = 1.0, deprecated = true];
  // Scale factor of face height to shift based on tilt look angle.
  optional float tilt_position_shift_scale = 16 [default = 0.25];
  // Scale factor of face width to shift based on roll look angle.
  optional float roll_position_shift_scale = 17 [default = 0.7];
}
