/*
 * @Description: implement of x2base.proto
 * @Author: ruoting.ding@horizonl.ai
 * @Date: 2019-09-23 17:05:35
 * @LastEditors: hao.tian@horizon.ai
 * @LastEditTime: 2019-09-23 17:05:35
 * @Copyright 2017~2019 Horizon Robotics, Inc.
 */
syntax = "proto3";
package x3;
option optimize_for = LITE_RUNTIME;

/**
 * 字节数组
 * @type_ {1} 类型名称
 * @array_ {2} 字节数组
 */
message CharArray {
  string type_ = 1;
  bytes array_ = 2;
}

/**
 * Float 数组
 * @type_ {1} 类型名称
 * @value_ {2} 值
 */
message FloatArray {
  string type_ = 1;
  repeated float value_ = 2;
}

/**
 * Float 2维矩阵
 * @type_ {1} 类型名称
 * @arrays_ {2} float数组
 */
message FloatMatrix {
  string type_ = 1;
  repeated FloatArray arrays_ = 2;
}

/**
 * 坐标点
 * @x_ {1} x坐标
 * @y_ {2} y坐标
 * @score_ {3} 置信度
 */
message Point {
  float x_ = 1;
  float y_ = 2;
  float score_ = 3;
}

/**
 * 坐标点集合
 * @type_ {1} 类型名称
 * @points_ {2} 坐标点集合
 */
message Points {
  string type_ = 1;
  repeated Point points_ = 2;
}

/**
 * 检测框
 * @type_ {1} 类型名称
 * @top_left_ {2} 左上点
 * @bottom_right_ {3} 右下点
 */
message Box {
  string type_ = 1;
  Point top_left_ = 2;
  Point bottom_right_ = 3;
  float score = 4;
}

/**
 * 属性
 * @type_ {1} 类型名称，包括年龄、性别、眼镜、口罩、活体信息、车辆信息、非机动车信息,道路状况
 * @value_ {2} 值
 * @score_ {3} 置信度
 */
message Attributes {
  string type_ = 1;
  float value_ = 2;
  string value_string_ = 3;
  float score_ = 4;
}

/**
 *  底库检索结果
 * @db_type_ {1} 底库名称
 * @match_id_ {2} 匹配目标ID
 * @distance_ {3} 距离
 * @similarity_ {4} 相似度
 */
message DBResult {
  string db_type_ = 1;
  string match_id_ = 2;
  float distance_ = 3;
  float similarity_ = 4;
}

/**
 *  图片信息
 * @buf_ {1} 图片二进制流
 * @buf_ {2} 图片类型，如：灰度图、YUV420、NV21、NV12、BGR、JPEG
 * @width_ {3} 图片宽度
 * @height_ {4} 图片高度
 */
message Image {
  bytes buf_ = 1;
  string type_ = 2;
  uint32 width_ = 3;
  uint32 height_ = 4;
}

/**
 * 能力类型
 * @type_ {1} 能力名称名称
 * @array_{2} 布尔值
 */
message Enable {
  string type_ = 1;
  bool value_ = 2;
}

/**
 * 范围类型
 * @type_ {1} 类型名称
 * @value_ {2} 值
 */
message Threshold {
  string type_ = 1;
  float value_ = 2;
}

/**
 * 模式类型
 * @type_ {1} 类型名称
 * @value_ {2} 值
 */
message Mode {
  string type_ = 1;
  string value_ = 2;
}

/**
 * 智能帧跟踪目标信息
 * @type_ {1} 跟踪目标类型名称，如：人、车、动物、非机动车
 * @track_id_ {2} 跟踪目标ID号
 * @imgs_ {3} 抓拍图
 * @sub_targets_ {4} 子目标，目前车牌作为车的子目标存在
 * @boxes_ {5} 检测框集合
 * @attributes_  {6} 属性集合，如：年龄、性别、眼镜、口罩、活体信息、车辆类型、车辆颜色、车辆速度、车辆所在车道
 * @points_  {7} 多个坐标点集合，如：人脸关键点、人体骨骼点、人体分割图的坐标点
 * @float_arrays_  {8} Float点集合，比如人脸姿态，gis信息
 * @float_matrixs_  {9} Float矩阵集合，比如人体分割结果
 * @char_arrays_ {10} 字节数组集合，如加密后的特征
 */
message Target {
  string type_ = 1;
  uint64 track_id_ = 2;
  repeated Image imgs_ = 3;
  repeated Target sub_targets_ = 4;
  repeated Box boxes_ = 5;
  repeated Attributes attributes_ = 6;
  repeated Points points_ = 7;
  repeated FloatArray float_arrays_ = 8;
  repeated FloatMatrix float_matrixs_ = 9;
  repeated CharArray char_arrays_ = 10;

}

/**
 * 智能帧信息
 * @timestamp_ {1} 原视频帧的时间戳
 * @error_code_ {2} 错误码
 * @targets {3} 跟踪目标集合
 */
message SmartFrameMessage {
  fixed64 timestamp_ = 1;
  uint32 error_code_ = 2;
  repeated Target targets_ = 3;
}

/**
 *  抓拍图信息
 * @type_ {1} 抓拍类型名称，如：人脸抓拍图、人体抓拍图、车辆抓拍图
 * @timestamp_ {2} 抓拍图对应原视频帧的时间戳,作为ID使用
 * @img_ {3} 抓拍图
 * @boxes_ {4} 一个抓拍图里感兴趣的检测框集合
 * @attributes_ {5} 属性集合，如：年龄、性别、图片质量
 * @points_ {6} 二维坐标点集合，如：人脸关键点集合
 * @float_arrays_ {7} Float点集合，比如人脸姿态，未加密的特征
 * @char_arrays_ {8} 字节数组集合，如加密后的特征
 */
message Capture {
  string type_ = 1;
  fixed64 timestamp_ = 2;
  Image img_ = 3;
  repeated Box boxes_ = 4;
  repeated Attributes attributes_ = 5;
  repeated Points points_ = 6;
  repeated FloatArray float_arrays_ = 7;
  repeated CharArray char_arrays_ = 8;
}

/**
 * 单目标抓拍信息
 * @type_ {1} 跟踪目标类型名称，如：人、车、动物
 * @track_id_ {2} 跟踪目标ID
 * @captures_ {3} 跟踪目标抓拍图信息集合
 * @db_results_ {4} 跟踪目标底库检索结果
 */
message CaptureTarget {
  string type_ = 1;
  uint64 track_id_ = 2;
  repeated Capture captures_ = 3;
  repeated DBResult db_results_ = 4;
}
/**
 * 抓拍帧信息
 * @targets {1} 抓拍目标信息集合
 */
message CaptureFrameMessage {
  repeated CaptureTarget targets_ = 1;
}

/**
 * 统计信息
 * @targets {1} 统计信息集合
 */
 message StatisticsMessage {
   repeated Attributes attributes_ = 1;
 }

/**
 * X2 Protobuf: Last Result Message
 * @smart_msg_ {1} smart frame info
 * @capture_msg_ {2} capture frame info
 */
message FrameMessage {
  SmartFrameMessage smart_msg_ = 1;
  CaptureFrameMessage capture_msg_ = 2;
  StatisticsMessage Statistics_msg_ = 3;
  Image img_ = 4;
}

/**
 * 能力配置
 * @type_ {1} 类型名称，可以为人脸、人体、附加等
 * @array_ {2} 能力数组
 */
message Capability {
  string type_ = 1;
  Enable cap_array_ = 2;
}

/**
 * 版本信息
 * @type_ {1} 类型名称，可以为系统镜像版本、APP版本等
 * @value_ {2} 版本信息
 */
message Version {
  string type_ = 1;
  string value_ = 2;
}

/**
 * 参数配置
 * @type_ {1}
 * 类型名称，可以设为人脸抓拍设置、人脸跟踪配置、人脸识别配置、系统配置等
 * @config_ {2} 配置数组
 */
message Config {
  string type_ = 1;
  repeated Threshold threshold_ = 2;
  repeated Mode mode_ = 3;
  repeated Box shield_ = 4;
}

/**
 * 状态信息
 * @type_ {1} 类型名称，可不填，为空
 * @timestamp_ {2} 时间戳，返回此状态获取的时间戳
 * @run_status_ {3} 运行状态
 */
message Status {
  enum RunStatus {
    Uknown = 0;
    Uninit = 1;
    Init = 2;
    Normal = 3;
    Abnormal = 4;
    Update = 5;
  }
  string type_ = 1;
  uint64 timestamp_ = 2;
  RunStatus run_status_ = 3;
}

/**
 * 命令信息
 * @type_ {1} 类型名称，可不填，为空
 * @timestamp_ {2} 时间戳，返回此状态获取的时间戳
 * @order_ {3} 命令类型
 */
message Command {
  enum Order {
    Unkown = 0;
    StartX2 = 1;
    StopX2 = 2;
    UpdateX2 = 3;
  }
  string type_ = 1;
  uint64 timestamp_ = 2;
  Order order_ = 3;
}

/**
 * 返回信息
 * @type_ {1} 返回类型名称，控制命令，普通配置，能力配置
 * @timestamp_ {2} 时间戳，返回此状态获取的时间戳
 * @response_ {3} 回复状态
 */
message Response {
  enum Ack {
    Uknown = 0;
    Success = 1;
    Fail = 2;
  }
  string type_ = 1;
  uint64 timestamp_ = 2;
  Ack ack_ = 3;
}

/**
 * 返回信息
 * @type_ {1} 类型名称，哪个log
 * @level_ {2} log等级
 */
message LogLevel {
  enum Level {
    X2_DEBUG = 0;
    X2_INFO = 1;
    X2_NOTICE = 2;
    X2_WARN = 3;
    X2_ERROR = 4;
    X2_FATAL = 5;
    X2_NONE = 6;
  }
  string type_ = 1;
  Level level_ = 2;
}

/**
 * Info信息集合
 * @status_ {1} 状态
 * @command_ {2} 命令
 * @response_ {3} 回复
 * @version_ {4} 版本
 * @capability_ {5} 能力
 */
message InfoMessage {
  Status status_ = 1;
  Command command_ = 2;
  LogLevel loglevel_ = 3;
  Response response_ = 4;
  repeated Config config_ = 5;
  repeated Version version_ = 6;
  repeated Capability capability_ = 7;
}