{ "annotations": [ {% set ns = namespace(firstFound=false) %} {% for annotation in data['annotations'] %} {% if annotation.class != undefined and annotation.object_type == "cuboid" or annotation.object_type == "polyline" or annotation.object_type == "polyline2d" or annotation.object_type == "polygongroup" or annotation.object_type == "polygon2d" or annotation.object_type == "rectangle" %} {% if ns.firstFound == true %} , {% else %} {% set ns.firstFound = true %} {% endif %} { "label": "{{ annotation.class }}", "_id": "{{ annotation._id }}", "id": "{{ annotation.id }}", "object_type": "{{ annotation.object_type }}", "identity" : {{annotation.identity}}, {% if annotation.object_type == "cuboid" %} "position": [ {{ annotation.geometry.position.x }} , {{ annotation.geometry.position.y }}, {{ annotation.geometry.position.z }} ], "orientation": {{ [ annotation.geometry.rotation.x, annotation.geometry.rotation.y, annotation.geometry.rotation.z ] | toQuaternion }}, "dimension": [{{ annotation.geometry.boxSize.x }} , {{ annotation.geometry.boxSize.y }}, {{ annotation.geometry.boxSize.z }}], {% elif annotation.object_type == "polyline" %} "position": [ {{ annotation.geometry.position.x }} , {{ annotation.geometry.position.y }}, {{ annotation.geometry.position.z }} ], "orientation": {{ [ annotation.geometry.rotation.x, annotation.geometry.rotation.y, annotation.geometry.rotation.z ] | toQuaternion }}, "points": [ {{ annotation.geometry.points | tojson }} ], {% elif annotation.object_type == "polyline2d" %} "position": [ {{ annotation.geometry.position.x }} , {{ annotation.geometry.position.y }}, {{ annotation.geometry.position.z }} ], "orientation": {{ [ annotation.geometry.rotation.x, annotation.geometry.rotation.y, annotation.geometry.rotation.z ] | toQuaternion }}, "points": [ {% for polygons_position_obj in annotation.geometry.points %} {{ polygons_position_obj | tojson }} {% if not loop.last %} , {% endif %} {% endfor %} ], "coordinates": [ {% for polygons_position_obj in annotation.geometry.coordinates %} {{ polygons_position_obj | tojson }} {% if not loop.last %} , {% endif %} {% endfor %} ], {% elif annotation.object_type == "polygongroup" %} "position": [ {{ annotation.geometry.position.x }} , {{ annotation.geometry.position.y }}, {{ annotation.geometry.position.z }} ], "orientation": {{ [ annotation.geometry.rotation.x, annotation.geometry.rotation.y, annotation.geometry.rotation.z ] | toQuaternion }}, "points": [ {% for polygons_val in annotation.geometry.polygons %} {% for polygons_position_obj in polygons_val.geometry.points %} {{ polygons_position_obj | tojson }} {% if not loop.last %} , {% endif %} {% endfor %} {% if not loop.last %} , {% endif %} {% endfor %} ], {# both objecttype coordinate data structure are same annotation.object_type == "rectangle" or annotation.object_type == "polygon2d" #} {% elif annotation.object_type == "rectangle" or annotation.object_type == "polygon2d" %} {% set content = data.tasks.metadata.help_images[annotation.referenceIndex].split("=")[-1] %} "image" : "{{ content.split("/")[-1] }}", "reference_folder": "{{content.split("/")[-2]}}", "coordinates":[ {% for eachcoord in annotation.geometry.coordinates %} { {% for eachpointkey in eachcoord %} "{{ eachpointkey }}" : {{ eachcoord[eachpointkey] }} {% if not loop.last %} , {% endif %} {% endfor %} } {% if not loop.last %} , {% endif %} {% endfor %} ], {% if annotation.geometry.pointCoordinates %} "pointCoordinates": {{ annotation.geometry.pointCoordinates | tojson }}, {% endif %} {% endif %} "taxonomy_attribute" : { {% for key in annotation.taxonomy_attribute %} {% if annotation.taxonomy_attribute[key] is boolean and key !="num_points" %} "{{ key }}" : {{ annotation.taxonomy_attribute[key]|lower }} {% elif annotation.taxonomy_attribute[key] is number and key !="num_points" %} "{{ key }}" : {{ annotation.taxonomy_attribute[key] }} {% elif annotation.taxonomy_attribute[key] is number and key =="num_points" %} "{{ key }}" : {{ (annotation.classId | int , annotation.identity, data['path']) |countPoints }} {% elif annotation.taxonomy_attribute[key].__class__.__name__ == 'list' %} "{{ key }}": [ {% for taxonomy in annotation.taxonomy_attribute[key] %} "{{ taxonomy }}" {% if not loop.last %} , {% endif %} {% endfor %} ] {% else %} "{{ key }}" : "{{ annotation.taxonomy_attribute[key] }}" {% endif %} {% if not loop.last %} , {% endif %} {% endfor %} } } {% endif %} {% endfor %} ], {# Start attributes #} {# Start taxonomy_attribute #} {# Start batchAttributes #} "batch_attribute": { {% for batchAttribute in data.operation.customData %} {% if 'batchAttributes' in batchAttribute.key %} {% for batchAtr_key, batchAtr_value in batchAttribute['data'].items() %} {# check the value type if boolen then convert it #} {% if batchAtr_value is boolean %} "{{ batchAtr_key }}" : {{ batchAtr_value |lower }} {# check the value is list or not #} {% elif batchAtr_value.__class__.__name__ == 'list' %} {# list value looping #} "{{ batchAtr_key }}": [ {% for sub_attr in batchAtr_value %} "{{ sub_attr }}" {% if not loop.last %} , {% endif %} {% endfor %} ] {% else %} "{{ batchAtr_key }}" : "{{ batchAtr_value }}" {% endif %} {% if not loop.last %} , {% endif %} {% endfor %} {% endif %} {% endfor %} }, {# End batchAttributes #} {# Start taskAttribute #} "frame_attribute": { {% if 'taskAttribute' in data.meta %} {% for taskAtr_key, taskAtr_value in data.meta.taskAttribute.items() %} {# check the value type if boolen then convert it #} {% if taskAtr_value is boolean %} "{{ taskAtr_key }}" : {{ taskAtr_value |lower }} {# check the value is list or not #} {% elif taskAtr_value.__class__.__name__ == 'list' %} {# list value looping #} "{{ taskAtr_key }}": [ {% for sub_attr in taskAtr_value %} "{{ sub_attr }}" {% if not loop.last %} , {% endif %} {% endfor %} ] {% else %} "{{ taskAtr_key }}" : "{{ taskAtr_value }}" {% endif %} {% if not loop.last %} , {% endif %} {% endfor %} {% endif %} }, {# End taskAttribute #} "meta_info": { "point_cloud": "{{ data.tasks.metadata.point_cloud }}", "frame_no": {{ data.tasks.task_seq_no }} }, "relationship": [ {% for items in data["annotations"] %} {% if 'relationship' in items %} {% for relation_val in items.relationship %} {{ relation_val | tojson }} {% if not loop.last %} , {% endif %} {% endfor %} {% endif %} {% endfor %} ] }