{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://vitals.example/schemas/biomodel-v0.1.json",
 "title": "Vitals Bio Model analyze() result",
 "type": "object",
 "required": [
  "schema_version",
  "video",
  "model",
  "animals"
 ],
 "properties": {
  "schema_version": {
   "const": "biomodel-v0.1"
  },
  "video": {
   "type": "object",
   "required": [
    "path",
    "fps",
    "width",
    "height",
    "n_frames",
    "step_s"
   ],
   "properties": {
    "path": {
     "type": "string"
    },
    "fps": {
     "type": "number"
    },
    "width": {
     "type": "integer"
    },
    "height": {
     "type": "integer"
    },
    "n_frames": {
     "type": "integer"
    },
    "step_s": {
     "type": "number"
    }
   }
  },
  "model": {
   "type": "object",
   "required": [
    "name",
    "version",
    "components",
    "shipped"
   ],
   "properties": {
    "name": {
     "type": "string"
    },
    "version": {
     "type": "string"
    },
    "components": {
     "type": "object",
     "additionalProperties": {
      "type": "string"
     }
    },
    "shipped": {
     "type": "boolean"
    }
   }
  },
  "embeddings": {
   "type": "array",
   "items": {
    "type": "array",
    "items": {
     "type": "number"
    }
   }
  },
  "notes": {
   "type": "array",
   "items": {
    "type": "string"
   }
  },
  "animals": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "identity",
     "species",
     "frames",
     "state"
    ],
    "properties": {
     "identity": {
      "type": "object",
      "required": [
       "track_id"
      ],
      "properties": {
       "track_id": {
        "type": "integer"
       },
       "identity_id": {
        "type": [
         "string",
         "null"
        ]
       },
       "confidence": {
        "type": [
         "number",
         "null"
        ]
       },
       "embedding_index": {
        "type": [
         "integer",
         "null"
        ]
       }
      }
     },
     "species": {
      "enum": [
       "cattle",
       "horse",
       "dog",
       "sheep",
       "goat",
       "pig",
       "cat",
       "deer",
       "other"
      ]
     },
     "state": {
      "type": "object",
      "propertyNames": {
       "enum": [
        "calm",
        "stressed",
        "in_pain",
        "lame",
        "likely_unwell"
       ]
      },
      "additionalProperties": {
       "type": "object",
       "required": [
        "p",
        "validated",
        "basis",
        "label"
       ],
       "properties": {
        "p": {
         "type": [
          "number",
          "null"
         ]
        },
        "validated": {
         "type": "boolean"
        },
        "basis": {
         "type": "string"
        },
        "label": {
         "enum": [
          "REAL",
          "SIMULATED",
          "ESTIMATE",
          "EXPLORATORY"
         ]
        }
       }
      }
     },
     "frames": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "t_s",
        "frame_index",
        "box",
        "score"
       ],
       "properties": {
        "t_s": {
         "type": "number"
        },
        "frame_index": {
         "type": "integer"
        },
        "box": {
         "type": "array",
         "items": {
          "type": "number"
         },
         "minItems": 4,
         "maxItems": 4
        },
        "score": {
         "type": "number"
        },
        "pose": {
         "type": [
          "object",
          "null"
         ],
         "required": [
          "keypoints"
         ],
         "properties": {
          "keypoints": {
           "type": "array",
           "items": {
            "type": "array",
            "items": {
             "type": "number"
            },
            "minItems": 3,
            "maxItems": 3
           },
           "minItems": 17,
           "maxItems": 17
          },
          "model": {
           "type": "string"
          }
         }
        },
        "behaviour": {
         "type": "object",
         "propertyNames": {
          "enum": [
           "lying",
           "standing",
           "walking",
           "running",
           "eating",
           "drinking",
           "grooming",
           "unknown"
          ]
         },
         "additionalProperties": {
          "type": "number"
         }
        },
        "forecast": {
         "type": [
          "object",
          "null"
         ],
         "required": [
          "horizons_s",
          "centre",
          "centre_sigma"
         ],
         "properties": {
          "horizons_s": {
           "type": "array",
           "items": {
            "type": "number"
           }
          },
          "centre": {
           "type": "array",
           "items": {
            "type": "array",
            "items": {
             "type": "number"
            },
            "minItems": 2,
            "maxItems": 2
           }
          },
          "centre_sigma": {
           "type": "array",
           "items": {
            "type": "number"
           }
          },
          "keypoints": {
           "type": [
            "array",
            "null"
           ]
          },
          "keypoints_sigma": {
           "type": [
            "array",
            "null"
           ]
          },
          "intent": {
           "type": "string"
          },
          "model": {
           "type": "string"
          },
          "p_stay": {
           "type": [
            "number",
            "null"
           ]
          },
          "modes": {
           "type": [
            "array",
            "null"
           ],
           "items": {
            "type": "object",
            "required": [
             "weight",
             "centre"
            ]
           }
          }
         }
        }
       }
      }
     }
    }
   }
  }
 }
}
