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


Python boxes.clip_xyxy_to_image方法代码示例

本文整理汇总了Python中utils.boxes.clip_xyxy_to_image方法的典型用法代码示例。如果您正苦于以下问题:Python boxes.clip_xyxy_to_image方法的具体用法?Python boxes.clip_xyxy_to_image怎么用?Python boxes.clip_xyxy_to_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.boxes的用法示例。


在下文中一共展示了boxes.clip_xyxy_to_image方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_gt_annotations

# 需要导入模块: from utils import boxes [as 别名]
# 或者: from utils.boxes import clip_xyxy_to_image [as 别名]
def _add_gt_annotations(self, entry):
        """Add ground truth annotation metadata to an roidb entry."""
        ann_ids = self.COCO.getAnnIds(imgIds=entry['id'], iscrowd=None)
        objs = self.COCO.loadAnns(ann_ids)
        # Sanitize bboxes -- some are invalid
        valid_objs = []
        valid_segms = []
        width = entry['width']
        height = entry['height']
        for obj in objs:
            # crowd regions are RLE encoded and stored as dicts
            if obj['area'] < cfg.TRAIN.GT_MIN_AREA:
                continue
            if 'ignore' in obj and obj['ignore'] == 1:
                continue
            # Convert form (x1, y1, w, h) to (x1, y1, x2, y2)
            x1, y1, x2, y2 = box_utils.xywh_to_xyxy(obj['bbox'])
            x1, y1, x2, y2 = box_utils.clip_xyxy_to_image(
                x1, y1, x2, y2, height, width
            )
            # Require non-zero seg area and more than 1x1 box size
            if obj['area'] > 0 and x2 > x1 and y2 > y1:
                obj['clean_bbox'] = [x1, y1, x2, y2]
                valid_objs.append(obj)
        num_valid_objs = len(valid_objs)

        gt_classes = np.zeros((num_valid_objs), dtype=entry['gt_classes'].dtype)
        for ix, obj in enumerate(valid_objs):
            cls = self.json_category_id_to_contiguous_id[obj['category_id']]
            gt_classes[ix] = cls

        for cls in gt_classes:
            entry['gt_classes'][0, cls] = 1 
开发者ID:ppengtang,项目名称:pcl.pytorch,代码行数:35,代码来源:json_dataset.py


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