The ResultV2 struct represents the outcome of a classification analysis in either the /classify?sync=true or /result/{id} endpoint response. It includes various fields that offer detailed information about the analysis, its status, related metadata, and video specifics.

type ResultV2 struct {
	ID              primitive.ObjectID  `json:"id,omitempty"`
	Status          *Status             `json:"status,omitempty" bson:"status,omitempty"`
	ParentID        *primitive.ObjectID `json:"parent_id,omitempty"`
	CameraID        string              `json:"camera_id,omitempty"`
	AnalyseID       *int                `json:"analyse_id,omitempty"`
	Tenant          string              `json:"tenant"`
	Duration        int64               `json:"duration"`
	DurationSeconds int                 `json:"duration_seconds"`
	Model           string              `json:"model,omitempty"`
	Version         string              `json:"version,omitempty"`
	ErrorCode       int                 `json:"error_code"`
	ErrorMessage    string              `json:"error_msg"`

	Risk         string                `json:"risk"`
	Labels       []string              `json:"labels"`
	Scores       JsonMap               `json:"scores,omitempty"`
	VideoDetails *ResultVideoDetailsV2 `json:"video,omitempty"`

	Metadata  JsonMap   `json:"metadata,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	StartedAt time.Time `json:"started_at,omitempty"`
}

type ClassifyStatus string

const (
	Accepted   ClassifyStatus = "accepted"
	InProgress ClassifyStatus = "in-progress"
	Done       ClassifyStatus = "done"
	Error      ClassifyStatus = "error"
	Timeout    ClassifyStatus = "timeout"
)

// Status struct
type Status struct {
	Classify ClassifyStatus `json:"classify"`
	Video    ClassifyStatus `json:"video"`
}

type ResultVideoDetailsV2 struct {
	Videoname  string  `json:"videoname" bson:"videoname"`
	Filesize   int     `json:"filesize" bson:"filesize"`
	VideoSpecs JsonMap `json:"specs,omitempty" bson:"specs"`
}

Example

// API_KEY is not specified 403
{
  "success": false,
  "error": "no access to current endpoint, make sure you are using correct API key"
}

// Async response
{
  "id": "6662efdb5200108549e3ac2b",
  "accepted_at": "2024-06-07T13:32:43.81196258+02:00"
}

// Sync response
{
  "id": "6662f5c1f897618de43f0bbd",
  "status": {
    "classify": "accepted",
    "video": "accepted"
  },
  "camera_id": "134188-VI08",
  "tenant": "test",
  "duration": 1434714,
  "duration_seconds": 1,
  "model": "noname",
  "version": "2.0.16123",
  "error_code": 0,
  "error_msg": "",
  "risk": "",
  "labels": [
    "intrusion"
  ],
  "scores": {
    "person": 0.12695148061787767,
    "plant": 0.049358549524389075,
    "spider": 0.00343773873185638,
    "web": 0.004425417528239508,
    "wind": 0.007171697000292765,
    "animal": 0.06220918576737605,
    "flag": 0.8295322694836862,
    "other": 0.020228226668765597,
    "text": 0.000977604282076755,
    "vehicule": 0.8928721973019503,
    "NOTHING": 0.00025552011262380115,
    "intrusion": 0.918744163159948,
    "rain": 0.004554292405135713
  },
  "video": {
    "videoname": "video.mp4",
    "filesize": 246792,
    "specs": {
      "duration": 2.3,
      "fps": 2.608695652173913,
      "original.fps": 3,
      "original.height": 480,
      "original.width": 640,
      "width": 426,
      "height": 320,
      "nframes": 6,
      "original.nframes": 6
    }
  },
  "metadata": {
    "parc_origine": "XX",
    "client_id": 134188,
    "code_msg": "VI08",
    "no_trans": "20818"
  },
  "created_at": "2024-06-07T13:57:55.230265+02:00",
  "started_at": "2024-06-07T13:57:55.230265+02:00"
}

Fields Description

Basic Information

Field JSON Representation Description
ID id The unique identifier of the result object.
CameraID camera_id The unique identifier of the camera used for capturing the video.
Tenant tenant The identifier of the tenant. This field is mandatory.
Model model The model used for the analysis. This field is reserved for future needs to identify the model used for classification. It is optional.
Version version The version of the model used for the analysis. This field is optional.

The camera_id is generated from the metadata field using the following logic:

camera_id = metadata.client_id + metadata.camera_id // if camera_id and client_id are provided
camera_id = metadata.client_id + metadata.code_msg // if camera_id and code_msg are provided 

Duration

Field Type Description JSON Representation
Duration int64 The classification duration of the video in milliseconds. duration
DurationSeconds int The classification duration of the video in seconds. duration_seconds

Status and Errors

Field Type Description JSON Representation
Status Status The status of the analysis, encapsulated in a nested Status struct. This field is optional. status
ErrorCode int A code indicating any error that occurred during the analysis. error_code
ErrorMessage string A detailed message describing any error that occurred during the analysis. error_msg

Analysis Results

Field Type Description JSON Representation
Risk string The risk level identified by the analysis. It is derived from the scores using predefined thresholds: safe, high, and reject (default values: 0.1, 0.9, and 0.5 respectively). risk
Labels []string The labels assigned during the analysis, derived from the scores using the same thresholds. labels
Scores JsonMap A map of scores for each label. This field is optional and only includes objectives without scores if present. scores

Video Details

Field Type Description JSON Representation
VideoDetails ResultVideoDetailsV2 Details about the video, encapsulated in a nested ResultVideoDetailsV2 struct. This field is optional. video

Timestamps

Field Type Description JSON Representation
CreatedAt time.Time The timestamp when the analysis was created. This field is optional. created_at
StartedAt time.Time The timestamp when the analysis started. This field is optional. started_at