当前位置: 首页>>代码示例>>Python>>正文


Python objectify.ElementMaker方法代码示例

本文整理汇总了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 
开发者ID:CasiaFan,项目名称:Dataset_to_VOC_converter,代码行数:21,代码来源:anno_coco2voc.py

示例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 
开发者ID:CasiaFan,项目名称:Dataset_to_VOC_converter,代码行数:23,代码来源:anno_coco2voc.py

示例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 
开发者ID:CasiaFan,项目名称:Dataset_to_VOC_converter,代码行数:44,代码来源:anno_hda2voc.py


注:本文中的lxml.objectify.ElementMaker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。