{ "reference_id": "sample_reference_id", "data": { "video_data": { "frames": [ { "frame_id": "frame001", "src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+1" }, { "frame_id": "frame002", "src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+2" } ] } }, "tag": "track_bounding_boxes", "batch_id": "72c888f6-b365-4f27-ad57-d7841da2de0c" }
{ "data": { "job_id": "3f3e8675-ca69-46d7-aa34-96f90fcbb732", "reference_id": "001", "tag": "Sample-task" }, "success": true }
import requests import json """ Details for creating JOBS, project_id ->> ID of project in which job needed to be created x_api_key ->> secret api key to create JOBS tag ->> You can ask this from playment side batch_id ->> The batch in which JOB needed to be created """ project_id = '' x_api_key = '' tag = '' batch_id = '' #method that can be used to call the job creation api def Upload_jobs( DATA): base_url = f"https://api.playment.io/v0/projects/{project_id}/jobs" response = requests.post(base_url, headers={'x-api-key': x_api_key}, json=DATA) print(response.json()) if response.status_code >= 500: raise Exception("Something wrong at Playment's end") if 400 <= response.status_code < 500: raise Exception("Something wrong!!") return response.json() #method that can be used for batch creation def create_batch(batch_name,batch_description): headers = {'x-api-key':x_api_key} url = 'https://api.playment.io/v1/project/{}/batch'.format(project_id) data = {"project_id":project_id,"label":batch_name,"name":batch_name,"description":batch_description} response = requests.post(url=url,headers=headers,json=data) print(response.json()) if response.status_code >= 500: raise Exception("Something wrong at Playment's end") if 400 <= response.status_code < 500: raise Exception("Something wrong!!") return response.json()['data']['batch_id'] #list of frames in a single job frames = [ "https://example.com/image_url_1", "https://example.com/image_url_2" ] video_data = {'frames' : []} for frame_url in frames: frame_id = os.path.basename(os.path.normpath(frame_url)) frame_obj = {'src':frame_url,'frame_id':frame_id} video_data['frames'].append(frame_obj) #reference_id should be unique for each job reference_id="job1" job_data = { 'reference_id':reference_id, 'tag':api_tag, 'data':{'video_data':video_data}, 'batch_id' : new_batch_id } #helper method to print json data structure def to_dict(obj): return json.loads( json.dumps(obj, default=lambda o: getattr(o, '__dict__', str(o))) ) print(json.dumps(to_dict(job_data))) response = Upload_jobs(DATA=job_data) print(response.json())
{ "data": { "project_id": "", "reference_id": "001", "job_id": "fde54589-ebty-48lp-677a-03a0428ca836", "batch_id": "b99d241a-bb80-ghyi-po90-c37d4fead593", "status": "completed", "tag": "sample_project", "priority_weight": 5, "result": "https://playment-data-uploads.s3.ap-south-1.amazonaws.com/sample-result.json" }, "success": true }
{ "data": { "annotation_data": { "annotations": [ { "_id": "1a620df1-64a8-46ea-bc63-7446534e4870", "attributes": null, "color": "rgb(128,216,218)", "frames":{ "frame_001":{ "_id": "057cf1f5-6c15-4f29-9775-940cf27643f4", "points": { "p1": {"x": 0.17,"y": 0.58}, "p2": {"x": 0.26,"y": 0.58}, "p3": {"x": 0.26,"y": 0.49}, "p4": {"x": 0.17,"y": 0.49}, "p5": {"x": 0.24,"y": 0.51}, "p6": {"x": 0.35,"y": 0.52}, "p7": {"x": 0.35,"y": 0.36}, "p8": {"x": 0.25,"y": 0.37} }, "front": { "coordinates": ["p1","p2","p3","p4"] }, "side": { "coordinates": ["p2","p3","p5","p6"] }, "back": { "coordinates": ["p7","p8","p5","p6"] }, "attributes":{ "model_type" : {"value": "Sedan"}, "faces_visible": {"value": ["right","back"]} } }, "frame_002":{ "_id": "33abc3fe-9fbc-4d7c-b951-a1d1bfb6f840", "points": { "p1": {"x": 0.19,"y": 0.58}, "p2": {"x": 0.24,"y": 0.56}, "p3": {"x": 0.23,"y": 0.49}, "p4": {"x": 0.12,"y": 0.44}, "p5": {"x": 0.27,"y": 0.52}, "p6": {"x": 0.33,"y": 0.52}, "p7": {"x": 0.38,"y": 0.38}, "p8": {"x": 0.21,"y": 0.32} }, "front": { "coordinates": ["p1","p2","p3","p4"] }, "side": { "coordinates": ["p2","p3","p5","p6"] }, "back": { "coordinates": ["p7","p8","p5","p6"] }, "attributes":{ "model_type" : {"value": "Sedan"}, "faces_visible": {"value": ["right","back"]} } } }, "label": "bear", "origin": "manual", "source": "images", "state": "editable", "type": "cuboid" } ], "groups": null }, "video_data": { "frames": [ { "_id": "00000000-0000-0000-0000-000000000000", "frame_id": "bear_0000.png", "meta_data": null, "ref_id": "", "src": "http://dfnq1fss3rnqc.cloudfront.net/play/original/3e4379ec-2a5a-4d30-9772-c02d408b2fe9", "src_original": "https://playment-asmobi.s3.amazonaws.com/pilot_data/2D_animals/bear/bear_0000.png" }, { "_id": "00000000-0000-0000-0000-000000000000", "frame_id": "bear_0001.png", "meta_data": null, "ref_id": "", "src": "http://dfnq1fss3rnqc.cloudfront.net/play/original/9b282fcc-f328-4f2b-88e9-f0efad08fd05", "src_original": "https://playment-asmobi.s3.amazonaws.com/pilot_data/2D_animals/bear/bear_0001.png" } ] } } }

Result JSON Structure

Response KeyDescription
dataobject having annotation_data object and video_data
data.annotation_data.annotationsList of all the annotation tracks each having _id, label, frames and other attributes
data.annotation_data.annotations.[i]._idString The unique tracking ID for an instance of an object across the sequential data.
data.annotation_data.annotations.[i].framesA dictionary with the frame_id key and annotation details as the value
data.annotation_data.annotations.[i].frames.<frame_id>.pointsThe normalized coordinates dictionary of the points that correspond to the annotated cuboid.
data.annotation_data.annotations.[i].frames.<frame_id>.frontThe list of points that correspond to the front face of the cuboid
data.annotation_data.annotations.[i].frames.<frame_id>.sideThe list of points that correspond to the side face of the cuboid.
data.annotation_data.annotations.[i].frames.<frame_id>.backThe list of points that correspond to the ba face of the cuboid.
data.annotation_data.annotations.[i].frames.<frame_id>._idString The unique ID for a frame instance of a tracker ie. an annotation
data.annotation_data.annotations.[i].frames.<frame_id>.attributesFrame level attribute dictionary for the given annotation
data.video_dataObject It is the input data, having list of frames
data.video_data.frames.[i].src_originalString source of input frame provided by client