syntax = "proto3";

package is.vision;

option java_package = "com.is.vision";
option java_multiple_files = true;

import "is_msgs/common.proto";
import "is_msgs/image.proto";
import "google/protobuf/timestamp.proto";

// Define messages for the camera gateway and calibration services

message CameraSetting {
  bool automatic = 1; // True if the camera should automatically assign this parameter
  float ratio = 2; // Ratio assigned to the parameter where 0.0 is the lowest value and 1.0 the highest
}

message CameraSettings {
  CameraSetting brightness = 1;
  CameraSetting exposure = 2;
  CameraSetting focus = 3;
  CameraSetting gain = 4;
  CameraSetting gamma = 5;
  CameraSetting hue = 6;
  CameraSetting iris = 7;
  CameraSetting saturation = 8;
  CameraSetting sharpness = 9;
  CameraSetting shutter = 10;
  CameraSetting white_balance_bu = 11;
  CameraSetting white_balance_rv = 12;
  CameraSetting zoom = 13;
}

message CameraConfig {
  common.SamplingSettings sampling = 1;
  ImageSettings image = 2;
  CameraSettings camera = 3;
}

enum CameraConfigFields {
  ALL = 0;
  SAMPLING_SETTINGS = 1;
  IMAGE_SETTINGS = 2;
  CAMERA_SETTINGS  = 3;
}

message CameraCalibration { 
  string id = 1;  // camera id
  google.protobuf.Timestamp calibrated_at = 2; // when the calibration was performed
  double error = 3; // average reprojection error
  vision.Resolution resolution = 4; // resolution used during calibration

  common.Tensor intrinsic = 5; // intrinsic matrix with shape=[3,3]
  common.Tensor distortion = 6; // distortion coefficients with shape=[1,5]
  
  // used to transform from the camera frame to a world frame and vice versa
  repeated FrameTransformation extrinsic = 7;
}

message FrameTransformation {
  string from = 1;
  string to = 2;
  common.Tensor tf = 3; // transformation matrix [R T; 0 1] with shape = [4,4]
}
