Esempio n. 1
0
    # 初始化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
    # 随机obj1的初始位置及大小
    pos2 = func2.RandomPoint([50, 50], [300, 300])
    size2 = im2.shape[0:2]
    # 初始化obj1
    obj2_rect = Rect(pos2, size2)
    obj2_data = RectArray(obj2_rect, 3)
    obj2_data.SetRectData(im2)
    obj2_datamask = RectArray(obj2_rect, 1, dtype=np.bool)
    obj2_datamask.SetValue(immask2)
    obj2 = Obj(obj2_data, obj2_datamask)
    # 生成、保存
    mainboard.Gen()
    name_dict = dict(zip(['imB', 'flowBA', 'flowBA_viz'],
                         name[name_front: name_front+3]))
    name_front += 3
    mainboard.Save(name_dict)

    # =============== 第一次以后的生成区域 ==================
    for _ in range(board_num - 1):
        # 生成背景
        obj_back = obj_list[0]
        trans_back_opts = trans_opts_list[0]
        trans_back = Trans(obj_back)
        # <这里插入对opts的修改>
        trans_back_opts['xz'] += func.NormalAngle(0, 0.15, 'd')
        trans_back_opts['py'] += func.NormalDis(0, 1)
        trans_back_opts['sf'] += func.NormalScale(0, 0.004)
        # <>
        trans_back.QuickTrans(['py', 'xz', 'sf'], [trans_back_opts])
        mainboard = Board(board_size)
        mainboard.addTrans(trans_back)
        # 保存修改
        obj_list[0] = trans_back.obj_imB
        trans_opts_list[0] = trans_back_opts
        for j in range(1, obj_num+1):  # 有背景要加一
            obj = obj_list[j]
            trans_opts = trans_opts_list[j]
            trans = Trans(obj)
            # 这里对opt里面的内容进行微调
            trans_opts['xz'] += func.NormalAngle(0, 1, 'd')
            trans_opts['py'] += func.NormalDis(0, 2)