本文整理汇总了Python中lxml.objectify.ElementMaker方法的典型用法代码示例。如果您正苦于以下问题:Python objectify.ElementMaker方法的具体用法?Python objectify.ElementMaker怎么用?Python objectify.ElementMaker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lxml.objectify
的用法示例。
在下文中一共展示了objectify.ElementMaker方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: instance2xml_base
# 需要导入模块: from lxml import objectify [as 别名]
# 或者: from lxml.objectify import ElementMaker [as 别名]
def instance2xml_base(anno):
E = objectify.ElementMaker(annotate=False)
anno_tree = E.annotation(
E.folder('VOC2014_instance/{}'.format(anno['category_id'])),
E.filename(anno['file_name']),
E.source(
E.database('MS COCO 2014'),
E.annotation('MS COCO 2014'),
E.image('Flickr'),
E.url(anno['coco_url'])
),
E.size(
E.width(anno['width']),
E.height(anno['height']),
E.depth(3)
),
E.segmented(0),
)
return anno_tree
示例2: instance2xml_bbox
# 需要导入模块: from lxml import objectify [as 别名]
# 或者: from lxml.objectify import ElementMaker [as 别名]
def instance2xml_bbox(anno, bbox_type='xyxy'):
"""bbox_type: xyxy (xmin, ymin, xmax, ymax); xywh (xmin, ymin, width, height)"""
assert bbox_type in ['xyxy', 'xywh']
if bbox_type == 'xyxy':
xmin, ymin, w, h = anno['bbox']
xmax = xmin+w
ymax = ymin+h
else:
xmin, ymin, xmax, ymax = anno['bbox']
E = objectify.ElementMaker(annotate=False)
anno_tree = E.object(
E.name(anno['category_id']),
E.bndbox(
E.xmin(xmin),
E.ymin(ymin),
E.xmax(xmax),
E.ymax(ymax)
),
E.difficult(anno['iscrowd'])
)
return anno_tree
示例3: instance2xml_base
# 需要导入模块: from lxml import objectify [as 别名]
# 或者: from lxml.objectify import ElementMaker [as 别名]
def instance2xml_base(anno, bbox_type='xyxy'):
"""bbox_type: xyxy (xmin, ymin, xmax, ymax); xywh (xmin, ymin, width, height)"""
assert bbox_type in ['xyxy', 'xywh']
camera_id = "camera" + str(anno["filename"].split("_")[0])
E = objectify.ElementMaker(annotate=False)
anno_tree = E.annotation(
E.folder('VOC2014_instance/person'),
E.filename(anno["filename"]),
E.source(
E.database('HDA V1.3'),
E.annotation('HDA V1.3'),
E.image('HDA V1.3'),
E.url('None')
),
E.size(
E.width(cam_size[camera_id][0]),
E.height(cam_size[camera_id][1]),
E.depth(3)
),
E.segmented(0),
)
for bbox in anno['bbox']:
if bbox_type == 'xyxy':
xmin, ymin, w, h = bbox
xmax = xmin+w
ymax = ymin+h
else:
xmin, ymin, xmax, ymax = bbox
E = objectify.ElementMaker(annotate=False)
anno_tree.append(
E.object(
E.name("person"),
E.bndbox(
E.xmin(xmin),
E.ymin(ymin),
E.xmax(xmax),
E.ymax(ymax)
),
E.difficult(0)
)
)
return anno_tree