im = np.array(img)
        immask = np.array(imgmask) > 0
        pos = func2.RandomPoint(obj_minIniPos, obj_maxIniPos)
        size = (im.shape[1],im.shape[0])
        # 初始化obj
        obj_rect = Rect(pos, size)
        obj_data = RectArray(obj_rect, 3)
        obj_data.SetRectData(im)
        obj_datamask = RectArray(obj_rect, 1, dtype=np.bool)
        obj_datamask.SetValue(immask)
        obj = Obj(obj_data, obj_datamask)
        # 通过trans初始化obj的姿态,初始化不保存光流
        trans = Trans(obj)
        trans_opts = GetTransOpts()
        trans_opts['xz_theta'] = func.RandomAngle(-np.pi/2, np.pi/2)
        trans_opts['py'] = func.RandomDis((-100, -100), (100, 100))
        trans.QuickTrans(['py', 'xz'], [trans_opts])
        # 更新board
        initboard.addTrans(trans)
        # 存入列表
        obj_list.append(trans.obj_imB)
    # 生成、保存
    initboard.Gen()
    name_front = 0
    initboard.Save({'imB': name[name_front]})
    name_front += 1

    # =============== 第一次生成区域 ==================
    # 生成背景
    obj_back = obj_list[0]
    trans_back = Trans(obj_back)
Example #2
0
    # 1111111111111111111111111111111
    # 随机obj1的初始位置及大小
    pos1 = func2.RandomPoint([50, 50], [300, 300])
    size1 = im.shape[0:2]
    # 初始化obj1
    obj1_rect = Rect(pos1, size1)
    obj1_data = RectArray(obj1_rect, 3)
    obj1_data.SetRectData(im)
    obj1_datamask = RectArray(obj1_rect, 1, dtype=np.bool)
    obj1_datamask.SetValue(immask)
    obj1 = Obj(obj1_data, obj1_datamask)
    # 初始化trans
    trans1_0 = Trans(obj1)
    trans_opts = GetTransOpts()
    trans_opts['xz_theta'] = func.RandomAngle(-np.pi/2, np.pi/2)
    trans_opts['py'] = func.RandomDis((-100, -100), (100, 100))
    trans1_0.QuickTrans(['py', 'xz'], trans_opts)

    trans1_1 = Trans(trans1_0.obj_imB)
    trans_opts = GetTransOpts()
    trans_opts['xz_theta'] = func.RandomAngle(-np.pi/36, np.pi/36)
    trans_opts['py'] = func.RandomDis((-40, -40), (40, 40))
    trans1_1.QuickTrans(['py', 'xz'], trans_opts)

    trans1_2 = Trans(trans1_1.obj_imB)
    trans_opts['xz_theta'] += func.NormalAngle(0, 1, 'd')
    trans_opts['py'] += func.NormalDis(0, 2)
    trans1_2.QuickTrans(['py', 'xz'], trans_opts)

    ###############################################
    # 2222222222222222222222222222222
Example #3
0
        im = np.array(img)
        immask = np.array(imgmask) > 0
        pos = func2.RandomPoint([0, 0], board_size)
        size = (im.shape[1], im.shape[0])
        # 初始化obj
        obj_rect = Rect(pos, size)
        obj_data = RectArray(obj_rect, 3)
        obj_data.SetRectData(im)
        obj_datamask = RectArray(obj_rect, 1, dtype=np.bool)
        obj_datamask.SetValue(immask)
        obj = Obj(obj_data, obj_datamask)
        # 通过trans初始化obj的姿态,初始化不保存光流
        trans = Trans(obj)
        trans_opts = GetTransOpts()
        trans_opts['xz_theta'] = func.RandomAngle(-np.pi / 2, np.pi / 2)
        trans_opts['py'] = func.RandomDis((-100, -100), (100, 100))
        trans.QuickTrans(['py', 'xz'], trans_opts)
        # 更新board
        initboard.addTrans(trans)
        # 存入列表
        obj_list.append(trans.obj_imB)
    # 生成、保存
    initboard.Gen()
    name_front = 0
    initboard.Save({'imB': name[name_front]})
    name_front += 1

    # =============== 第一次生成区域 ==================
    # 生成背景
    obj_back = obj_list[0]
    trans_back = Trans(obj_back)