11111

if neg < self.aug_settings['occ_background']['prob']:
    # 在当前图像中找到一块背景区域作为遮挡块
    occ_image = search_image
    occ_image_, occ_box_, _ = self.crop127255(occ_image, search_bbox, self.search_size)
    occ_bbox = random_background(occ_image_, occ_box_,
                                 min_rate=self.aug_settings['occ_background']['crop_rate_min'],
                                 max_rate=self.aug_settings['occ_background']['crop_rate_max'],
                                 protect_settings=rand(
                                     self.aug_settings['occ_background']['protect_rate_min'],
                                     self.aug_settings['occ_background']['protect_rate_max']))
    occ_bbox = list(map(int, occ_bbox))
    # search_bbox = list(map(int, search_bbox))
    cv2.rectangle(occ_image, (occ_bbox[0], occ_bbox[1]), (occ_bbox[2], occ_bbox[3]), (0, 255, 0), 3)
    # cv2.rectangle(occ_image, (search_bbox[0], search_bbox[1]), (search_bbox[2], search_bbox[3]), (0, 255, 0), 3)
    cv2.imshow('occ_name', occ_image_)
    cv2.waitKey(100)
    if occ_bbox is not None:
        # occ_image_, occ_box_, _ = self.crop127255(occ_image, occ_bbox, self.search_size)
        # # 遮挡块需要带一定背景区域
        # occ_box_ = box2roi(occ_box, rate_w=self.roi_rate(), rate_h=self.roi_rate(),
        #                    boundary=[255, 255])
        box = list(map(int, occ_bbox))
        # 裁剪出遮挡块
        occ = occ_image_[box[1]: box[3] + 1, box[0]: box[2] + 1]
        # 将遮挡块覆盖到目标框位置上,并计算box被遮挡部分的占比
        search_img_, occed_box, overlap = random_occ(search_img, search_box, obj=occ,
                                                     center_rate=self.aug_settings['center_rate'],
                                                     try_num=self.aug_settings['try_num'],
                                                     overlap_thresh=self.aug_settings[
                                                         'overlap_thresh'])
        # 当目标大部分被完全覆盖时,才完成有效的遮挡扩增
        # if occed_box is not None and overlap > self.aug_settings['overlap_thresh']:
        search_img = search_img_
        pos = 0.0

# if neg < self.aug_settings['occ_background']['prob']:
# # 在当前图像中找到一块背景区域作为遮挡块
# occ_image = search_image
# occ_bbox = random_background(occ_image, search_bbox,
# min_rate=self.aug_settings['occ_background']['crop_rate_min'],
# max_rate=self.aug_settings['occ_background']['crop_rate_max'],
# protect_settings=rand(
# self.aug_settings['occ_background']['protect_rate_min'],
# self.aug_settings['occ_background']['protect_rate_max']))
# if occ_bbox is not None:
# occ_image_, occ_box, _ = self.crop127255(occ_image, occ_bbox, self.search_size)
# # 遮挡块需要带一定背景区域
# occ_box_ = box2roi(occ_box, rate_w=self.roi_rate(), rate_h=self.roi_rate(),
# boundary=[255, 255])
# box = list(map(int, occ_box_))
# # 裁剪出遮挡块
# occ = occ_image_[box[1]: box[3] + 1, box[0]: box[2] + 1]
# # 将遮挡块覆盖到目标框位置上,并计算box被遮挡部分的占比
# search_img_, occed_box, overlap = random_occ(search_img, search_box, obj=occ,
# center_rate=self.aug_settings['center_rate'],
# try_num=self.aug_settings['try_num'],
# overlap_thresh=self.aug_settings[
# 'overlap_thresh'])
# # 当目标大部分被完全覆盖时,才完成有效的遮挡扩增
# if occed_box is not None and overlap > self.aug_settings['overlap_thresh']:
# search_img = search_img_
# pos = 0.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值