本文整理匯總了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