-
Create the job as mentioned in Creating sensor-fusion annotation Job
POST
https://api.playment.io/v0/projects/<project_id>/jobs
Parameters
project_id
: To be passed in the URL
x-api-key
: Secret key to be passed as a header
{
"reference_id": "001",
"data": {
"sensor_data": {
"frames": [
{
"sensors": [
{
"sensor_id": "lidar",
"data_url": "",
"sensor_pose": {
"position": {
"x": 0,
"y": 0,
"z": 0
},
"heading": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
}
}
},
{
"sensor_id": "camera",
"data_url": "",
"sensor_pose": {
"position": {
"x": -0.8141599005737696,
"y": 1.6495307329711615,
"z": -1.5230365881437538
},
"heading": {
"w": 0.6867388282287469,
"x": 0.667745267519749,
"y": -0.21162707775631337,
"z": 0.19421642430111224
}
}
}
],
"ego_pose": {},
"frame_id": "0001"
},
{
"sensors": [
{
"sensor_id": "lidar",
"data_url": "",
"sensor_pose": {
"position": {
"x": 0,
"y": 0,
"z": 0
},
"heading": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
}
}
},
{
"sensor_id": "camera",
"data_url": "",
"sensor_pose": {
"position": {
"x": -0.8141599005737696,
"y": 1.6495307329711615,
"z": -1.5230365881437538
},
"heading": {
"w": 0.6867388282287469,
"x": 0.667745267519749,
"y": -0.21162707775631337,
"z": 0.19421642430111224
}
}
}
],
"ego_pose": {},
"frame_id": "0002"
}
],
"sensor_meta": [
{
"id": "lidar",
"name": "lidar",
"state": "editable",
"modality": "lidar",
"primary_view": true
},
{
"id": "18158562",
"name": "18158562",
"state": "editable",
"modality": "camera",
"primary_view": false,
"intrinsics": {
"cx": 0,
"cY": 0,
"fx": 0,
"fy": 0,
"k1": 0,
"k2": 0,
"k3": 0,
"k4": 0,
"p1": 0,
"p2": 0,
"skew": 0,
"scale_factor": 1
}
}
]
}
},
"tag": "track_3d_bounding_boxes"
}
{
"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 = ''
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()
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']
"""
Defining Sensor: This will contain detail about sensor's attributes.
:param _id: This is the sensor's id.
:param name: Name of the sensor.
:param primary_view: Only one of the sensor can have primary_view as true.
:param state(optional): If you want this sensor not to be annotated, provide state as non_editable. Default is editable.
:param modality: This is the type of sensor.
:param intrinsics: In case of a camera modality sensor we will need the sensor intrinsics.
This field should ideally become part of the sensor configuration, and not be sent as part of each Job.
"cx": principal point x value; default 0
"cy": principal point y value; default 0
"fx": focal length in x axis; default 0
"fy": focal length in y axis; default 0
"k1": 1st radial distortion coefficient; default 0
"k2": 2nd radial distortion coefficient; default 0
"k3": 3rd radial distortion coefficient; default 0
"k4": 4th radial distortion coefficient; default 0
"p1": 1st tangential distortion coefficient; default 0
"p2": 2nd tangential distortion coefficient; default 0
"skew": camera skew coefficient; default 0
"scale_factor": The factor by which the image has been downscaled (=2 if original image is twice as
large as the downscaled image)
"""
#Name the sensors, similarly you can define this for multiple cameras
lidar_sensor_id = 'lidar'
#Preparing Lidar Sensor
lidar_sensor = {"id": lidar_sensor_id, "name": "lidar", "primary_view": True, "modality": "lidar","state": "editable"}
#Preparing Camera Sensor for camera_1
camera_1_intrinsics = {
"cx": 0, "cy": 0, "fx": 0, "fy": 0,
"k1": 0, "k2": 0, "k3": 0, "k4": 0, "p1": 0, "p2": 0, "skew": 0, "scale_factor": 1}
camera_1 = {"id": "camera_1", "name": "camera_1", "primary_view": False, "modality": "camera",
"intrinsics": camera_1_intrinsics,"state": "editable"}
#Preparing Camera Sensor for camera_2
camera_2_intrinsics = {
"cx": 0, "cy": 0, "fx": 0, "fy": 0,
"k1": 0, "k2": 0, "k3": 0, "k4": 0, "p1": 0, "p2": 0, "skew": 0, "scale_factor": 1}
camera_2 = {"id": "camera_2", "name": "camera_2", "primary_view": False, "modality": "camera",
"intrinsics": camera_2_intrinsics,"state": "editable"}
#SENSOR META - it contains information about sensors and it is constant across all jobs of same sensor
sensor_meta = [lidar_sensor, camera_1, camera_2]
#Collect frames for every sensor.
lidar_frames = [
"https://example.com/pcd_url_1",
"https://example.com/pcd_url_2"
]
camera_1_frames = [
"https://example.com/image_url_1",
"https://example.com/image_url_2"
]
camera_2_frames = [
"https://example.com/image_url_3",
"https://example.com/image_url_4"
]
#Preparing job creation payload
sensor_data = {"frames" : [],"sensor_meta": sensor_meta}
for i in range(len(lidar_frames)):
reference_id = i
#Collect ego_pose if the data is in world frame of reference
ego_pose = {
"heading": {"w": 1, "x": 0,
"y": 0, "z": 0},
"position": {"x": 0, "y": 0, "z": 0}
}
frame_obj = {"ego_pose" : ego_pose, "frame_id" : str(i),"sensors":[]}
lidar_heading = {"w": w, "x": x, "y": y, "z": z}
lidar_position = {"x": 0, "y": 0, "z": 0}
lidar_sensor = {"data_url": lidar_frames[i], "sensor_id": lidar_sensor_id,
"sensor_pose": {"heading": lidar_heading, "position": lidar_position}}
camera_1_heading = {"w": w, "x": x, "y": y, "z": z}
camera_1_position = {"x": 0, "y": 0, "z": 0}
camera_1_sensor = {"data_url": camera_1_frames[i], "sensor_id": 'camera_1',
"sensor_pose": {"heading": camera_1_heading, "position": camera_1_position}}
camera_2_heading = {"w": w, "x": x, "y": y, "z": z}
camera_2_position = {"x": 0, "y": 0, "z": 0}
camera_2_sensor = {"data_url": camera_2_frames[i], "sensor_id": 'camera_2',
"sensor_pose": {"heading": camera_2_heading, "position": camera_2_position}}
frame_obj['sensors'].append(lidar_sensor)
frame_obj['sensors'].append(camera_1_sensor)
frame_obj['sensors'].append(camera_2_sensor)
sensor_data['frames'].append(frame_obj)
job_payload={"data":{"sensor_data":sensor_data}, "reference_id":str(reference_id)}
data = {"data": job_payload['data'], "reference_id": job_payload['reference_id'], 'tag': tag, "batch_id": batch_id}
def to_dict(obj):
return json.loads(
json.dumps(obj, default=lambda o: getattr(o, '__dict__', str(o)))
)
print(json.dumps(to_dict(data)))
response = Upload_jobs(DATA=data)
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z
SIZE 4 4 4
TYPE F F F
COUNT 1 1 1
WIDTH 47286
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 47286
DATA ascii
5075.773 3756.887 107.923
5076.011 3756.876 107.865
5076.116 3756.826 107.844
5076.860 3756.975 107.648
5077.045 3756.954 107.605
5077.237 3756.937 107.559
5077.441 3756.924 107.511
5077.599 3756.902 107.474
5077.780 3756.885 107.432
5077.955 3756.862 107.391
...
-
Fetching result as mentioned in Fetching Job Result
GET
https://api.playment.in/v0/projects/<project_id>/jobs/<job_id>
Parameters
project_id
: To be passed in the URL
x-api-key
: Secret key to be passed as a header
{
"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": "bee1e822-bb9b-410a-a416-c7130cca5b5d",
"type": "cuboid3d",
"color": "rgb(5,168,175)",
"label": "Car",
"state": "editable",
"frames": {
"frame_0": {
"_id": "bee1e822-bb9b-410a-a416-c7130cca5b5d",
"color": "rgb(5,168,175)",
"label": "Car",
"center": {
"x": 33.2095,
"y": -6.1638,
"z": 0.913
},
"rotation": {
"_w": 0.9996776528360268,
"_x": -0.008701209392179426,
"_y": -0.0006643620382208403,
"_z": 0.02384193780815747
},
"attributes": {
"Category": {
"state": "editable",
"value": "Vehicle labels"
}
},
"dimensions": {
"width": 1.8315,
"height": 1.6527,
"length": 3.965
}
}
},
"source": "pointcloud",
"attributes": null
},
{
"_id": "e69ed38a-7508-4f3d-9b42-aa10439978f1",
"type": "cuboid3d",
"color": "rgb(72,239,66)",
"label": "Car",
"state": "editable",
"frames": {
"frame_0": {
"_id": "e69ed38a-7508-4f3d-9b42-aa10439978f1",
"color": "rgb(72,239,66)",
"label": "Car",
"center": {
"x": 122.6532,
"y": -1.95,
"z": 0.4117
},
"rotation": {
"_w": 0.9999037940991701,
"_x": 0,
"_y": 0,
"_z": 0.013870924485587282
},
"attributes": {
"Category": {
"state": "editable",
"value": "Vehicle labels"
}
},
"dimensions": {
"width": 1.8823,
"height": 1.7756,
"length": 4.1087
}
}
},
"source": "pointcloud",
"attributes": null
}
]
},
"sensor_data": {
"frames": [
{
"ego_pose": {
"heading": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
},
"position": {
"x": 0,
"y": 0,
"z": 0
}
},
"frame_id": "frame_0",
"sensors": [
{
"data_url": "http://dfnq1fss3rnqc.cloudfront.net/play/original/88fbde2f-5b32-4808-91c0-fe3af2552645.pcd",
"sensor_id": "lidar",
"sensor_pose": {
"heading": {
"w": 0.6627956724998891,
"x": 0.03772385169916179,
"y": 0.012825160948057164,
"z": -0.7477394751932002
},
"position": {
"x": 1049.6552304820034,
"y": -20.01266766252521,
"z": 769.8467441293857
}
}
},
{
"data_url": "http://dfnq1fss3rnqc.cloudfront.net/play/original/3e33c15a-ade3-467c-94c2-d95b30740feb",
"sensor_id": "camera",
"sensor_pose": {
"heading": {
"w": -0.025162647454189176,
"x": 0.05412460222884347,
"y": 0.7506140390947211,
"z": -0.6580394615175337
},
"position": {
"x": 1049.7685642877848,
"y": -19.286409972145094,
"z": 769.9711274804768
}
}
}
]
}
],
"sensor_meta": [
{
"id": "lidar",
"modality": "lidar",
"name": "lidar",
"primary_view": true,
"state": "editable"
},
{
"id": "camera",
"intrinsics": {
"cx": 927.4147961835002,
"cy": 574.7566048238128,
"fx": 1730.2539135896652,
"fy": 1729.420783820776,
"k1": -0.1747206465958292,
"k2": 0.18648085386871863,
"k3": 0,
"k4": 0,
"p1": -0.00007009122284936536,
"p2": 0.000063885517134774,
"scale_factor": 1,
"skew": 0
},
"modality": "camera",
"name": "camera",
"primary_view": false,
"state": "editable"
}
]
}
}
}
Result JSON Structure
Response Key | Description |
---|---|
data | object having annotation_data and sensor_data objectannotation_data : object having annotations listsensor_data : object having frames list and sensor_meta list |
data.annotation_data.annotations | List of all the annotation tracks each having -_id : String unique id of the cuboidtype : String type of the annotationlabel : String label of the cuboidcolor : String color of the cuboid in RGB(r,g,b)attributes : object attribute dictionary for the given annotationframes : object frame dictionary with frame _d as keysource : String with value pointcloud |
data.annotation_data.annotations. frames.frame_id | object each having_id : String unique id of the cuboidlabel : String label of the cuboidcolor : String color of the cuboid in RGB(r,g,b)dimensions : object having length, width, and height of a cuboidcenter : object having x, y, and z coordinate of cuboid's centerrotations : object having rotational value of cuboid in quaternion (w,x,y,z)attributes : object attribute dictionary for the given frame |
data.sensor_data.frames | List of all the frames each havingframe_id : String uuid id of the trackego_pose : Object having heading and position of ego vehiclesensors : List of sensors |
data.sensor_data.frames.[i].sensors | List of all the sensors of that frame, each havingsensor_id : String iddata_url : String input urlsensor_pose : Object having heading and position of given sensor |
data.sensor_data.sensor_meta | List Contains a list of all the sensors with each having metadata information likeid : String id of sensor,name : String name of sensormodality : String modality/type of sensorintrinsic : Object In case of a camera modality sensor we will need the sensor intrinsic. Check the sample and definition below |