Open In Colab Open a Colab to go through the exercise of importing video annotations.

Supported annotations

To import annotations in Labelbox, you need to create the annotations payload. In this section, we provide this payload for every annotation type. NDJSON is the only format supported for video annotations.

Note: Global and frame-based classifications are supported on video assets. However, tool annotations are required to be frame-based.

Bounding box

// Bouding Box Frame Base Classification

bbox_annotation = {
    "name" : "bbox_video",
    "segments" : [{
        "keyframes" : [
            {
              "frame": 13, // A frame number must be passed for tool annotations 
              "bbox" : {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              }  
           },
           {
              "frame": 14,
              "bbox" : {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              }  
           },
           {
              "frame": 15,
              "bbox" : {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              }  
           }
        ]
      }
    ]
}

Classifications - Radio/Checklist (global and frame-based)

// Radio global classification
global_radio_classification = {
    "name": "radio_class_global", 
    "answer": { "name": "first_radio_answer" }
}

// Radio nested classification 

global_nested_classification = {
  'name': 'radio_question_nested',
  'answer': {'name': 'first_radio_question'},
  'classifications' : [
    {'name': 'sub_question_radio', 'answer': {'name': 'sub_answer'}}
   ]
}

// Checklist frame specific classifications 

frame_checklist_classification = {
    "name": "checklist_class", 
    "answer": [
        { "name": "first_checklist_answer" , "frames": [{"start": 29, "end": 35 }, {"start": 48, "end": 65}]},
        { "name": "second_checklist_answer", "frames": [{"start": 29, "end": 35 }, {"start": 48, "end": 65}]} 
  ]      
}

Classifications under frame base tools

Annotation tools with classifications only support using the feature's schema id and not the feature name. For this single case, you will need to extract the classification feature schema id and the answer feature schema id


frame_bbox_with_checklist_subclass = {
    "name": "bbox_class",
    "segments": [{
        "keyframes": [
            {
            "frame": 10,
            "bbox": {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              },
            "classifications" : [
              {'schemaId' : "<classificationFeatureSchemaId>", 'answer' : {'schemaId': "<answerFeatureSchemaId>" }}
            ]     
          },
          {  
          "frame": 11,
            "bbox": {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              },
            "classifications" : [
              {'schemaId' : "<classificationFeatureSchemaId>", 'answer' : {'schemaId': "<answerFeatureSchemaId>" }}
            ]  
          },
          {  
          "frame": 13,
            "bbox": {
                "top": 146.0,
                "left": 98.0,
                "height": 382.0,
                "width": 341.0
              },
            "classifications" : [
              {'schemaId' : "<classificationFeatureSchemaId>", 'answer' : {'schemaId': "<answerFeatureSchemaId>" }}
            ]  
          }
        ]
      }
    ]
}

Point

point_frame_annotation = {
  "name": "point_video", 
  "segments": [{
    "keyframes": [{
      "frame": 17,
      "point" : {
        "x": 660.134 ,
        "y": 407.926
      }
    }]
  }] 
}

Polyline

polyline_frame_annotation = {
  "name": "line_video_frame", 
  "segments": [
      {
        "keyframes": [
          {
            "frame": 5,
            "line": [{
              "x": 680,
              "y": 100
            },{
              "x": 100,
              "y": 190
            },{
              "x": 190,
              "y": 220
            }]
          },
          {
            "frame": 12,
            "line": [{
              "x": 680,
              "y": 280
            },{
              "x": 300,
              "y": 380
            },{
              "x": 400,
              "y": 460
            }]
          },
          {
            "frame": 20,
            "line": [{
              "x": 680,
              "y": 180
            },{
              "x": 100,
              "y": 200
            },{
              "x": 200,
              "y": 260
            }]
          }
        ]
      },
      {
        "keyframes": [
          {
            "frame": 24,
            "line": [{
              "x": 300,
              "y": 310
            },{
              "x": 330,
              "y": 430
            }]
          },
          {
            "frame": 45,
            "line": [{
              "x": 600,
              "y": 810
            },{
              "x": 900,
              "y": 930
            }]
          }
        ]
      }
    ]
}

Polygon

Not supported

Segmentation Mask

Not supported

Classification - free-form text

Not supported