// 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;

import "mediapipe/util/tracking/tracking.proto";

option java_package = "com.google.mediapipe.tracking";
option java_outer_classname = "BoxTrackerProto";

message BoxTrackerOptions {
  // Chunk size for caching files. Should be equal to those
  // written by the FlowPackagerCalculator.
  optional int32 caching_chunk_size_msec = 1 [default = 2500];

  // Chunk file format.
  optional string cache_file_format = 2 [default = "chunk_%04d"];

  // Number of simultaneous tracking requests.
  optional int32 num_tracking_workers = 3 [default = 8];

  // Maximum waiting time for next chunk, till function times out.
  optional int32 read_chunk_timeout_msec = 4 [default = 60000];

  // If set, box tracker will record the state for each computed TimedBox
  // across all paths.
  optional bool record_path_states = 5 [default = false];

  // Actual tracking options to be used for every step.
  optional TrackStepOptions track_step_options = 6;
}

// Next tag: 14
// Proto equivalent of struct TimedBox.
message TimedBoxProto {
  // Normalized coords - in [0, 1]
  optional float top = 1;
  optional float left = 2;
  optional float bottom = 3;
  optional float right = 4;
  // Rotation of box w.r.t. center in radians.
  optional float rotation = 7;
  optional MotionBoxState.Quad quad = 9;
  optional int64 time_msec = 5 [default = 0];

  // Unique per object id to disambiguate boxes.
  optional int32 id = 6 [default = -1];

  // Box lable name.
  optional string label = 13;

  // Confidence of box tracked in the range [0, 1], with 0 being least
  // confident, and 1 being most confident. A reasonable threshold is 0.5
  // to filter out unconfident boxes.
  optional float confidence = 8;

  // Aspect ratio (width / height) for the tracked rectangle in physical space.
  // If this field is provided, quad tracking will be performed using
  // 6 degrees of freedom perspective transform between physical rectangle and
  // frame quad. Otherwise, 8 degrees of freedom homography tracking between
  // adjacent frames will be used.
  optional float aspect_ratio = 10;

  // Whether or not to enable reacquisition functionality for this specific box.
  optional bool reacquisition = 11 [default = false];

  // Whether we want this box to be potentially grouped with other boxes
  // to track together. This is useful for tracking small boxes that lie
  // on a plane. For example, when we detect a plane,
  // track the plane, then all boxes within the plane can share the same
  // homography transform.
  optional bool request_grouping = 12 [default = false];
}

message TimedBoxProtoList {
  repeated TimedBoxProto box = 1;
}
