Exemplo n.º 1
0
    trans3_0.QuickTrans(['py', 'xz'], trans_opts)

    trans3_1 = Trans(trans3_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))
    trans3_1.QuickTrans(['py', 'xz'], trans_opts)

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

####################################
    mainboard1 = Board([640, 480])
    mainboard1.addTrans(trans_back)
    mainboard1.addTrans(trans1_1)
    mainboard1.addTrans(trans2_1)
    mainboard1.addTrans(trans3_1)
    mainboard1.Gen()
    mainboard1.Save(dict(zip(['imA', 'imB', 'flowAB_viz'],
                             name[0:3])))

    mainboard2 = Board([640, 480])
    mainboard2.addTrans(trans_back)
    mainboard2.addTrans(trans1_2)
    mainboard2.addTrans(trans2_2)
    mainboard2.addTrans(trans3_2)
    mainboard2.Gen()
    mainboard2.Save(dict(zip(['imB', 'flowAB_viz'],
                             name[3:])))
Exemplo n.º 2
0
size2 = [50, 50]

obj1_rect = Rect(pos, size)
obj1_data = RectArray(obj1_rect, 3)
obj1_data.SetColor([255, 0, 255])


obj1_datamask = RectArray(obj1_rect, 1, dtype=np.bool)
obj1_datamask.SetValue(True)

obj1_mask_rect = Rect(Point(75, 75), size2)
obj1_true_datamask = RectArray(obj1_mask_rect, 1, dtype=np.bool)
obj1_true_datamask.SetValue(False)

obj1_datamask.AddRectArray(obj1_true_datamask, CSYS='local')


obj1 = Obj(obj1_data, obj1_datamask)
trans = Trans(obj1)
pts = trans.GenTrans('py')
trans.ImposeTrans(pts)
#DisplayObject(obj1)
mainboard = Board([640, 480])
mainboard.addTrans(trans)
mainboard.Gen()
mainboard.Display('imA')
mainboard.Display('imB')
#print(obj1)
#look = obj1.data_
#look2 = obj1.dataMask_
Exemplo n.º 3
0
    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)
    # 另一种写法:
    # trans.GenTrans('py',trans_opts)
    # trans.GenTrans('xz',trans_opts)
    # trans.ImposeTrans()
    trans2 = Trans(trans.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))
    trans2.QuickTrans(['py', 'xz'], trans_opts)

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

    mainboard1 = Board([640, 480])
    mainboard1.addTrans(trans2)
    mainboard1.Gen()
    mainboard1.Save(dict(zip(['imA', 'imB', 'flowAB_viz'], name[0:3])))

    mainboard2 = Board([640, 480])
    mainboard2.addTrans(trans3)
    mainboard2.Gen()
    mainboard2.Save(dict(zip(['imB', 'flowAB_viz'], name[3:])))
    print(f'完成:{i}/{num}')
print('全部完成!')
Exemplo n.º 4
0
 # 设置背景对象
 backgroud = backgroundGenerator.RandomGet()
 backgroud = backgroud.resize(background_size)
 back_data.SetRectData(np.array(backgroud))
 back_datamask = RectArray(back_rect, 1, dtype=np.bool)
 back_datamask.SetValue(True)
 obj_back = Obj(back_data, back_datamask)
 # 生成背景变换
 trans_back = Trans(obj_back)
 trans_back_opts = GetTransOpts()
 trans_back.QuickTrans(['M'], [trans_back_opts])
 # 创建列表储存初始化的obj
 obj_list = [trans_back.obj_imB]  # 初始化obj列表
 # initboard 用于保存第一帧
 initboard = Board(board_size)
 initboard.addTrans(trans_back)
 # 初始化循环生成 obj
 for _ in range(obj_num):
     # 随机obj的初始位置及大小
     img,imgmask = materialGenerator.RandomGet()
     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)
Exemplo n.º 5
0
    obj3_datamask = RectArray(obj3_rect, 1, dtype=np.bool)
    obj3_datamask.SetValue(immask3)
    obj3 = Obj(obj3_data, obj3_datamask)

    trans3_0 = Trans(obj3)
    trans_opts = GetTransOpts()
    trans_opts['xz_theta'] = func.RandomAngle(-np.pi / 2, np.pi / 2)
    trans_opts['py'] = func.RandomDis((-100, -100), (100, 100))
    trans3_0.QuickTrans(['py', 'xz'], trans_opts)

    trans3_1 = Trans(trans3_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))
    trans3_1.QuickTrans(['py', 'xz'], trans_opts)

    mainboard1 = Board([640, 480])
    mainboard1.addTrans(trans1_1)
    mainboard1.addTrans(trans2_1)
    mainboard1.addTrans(trans3_1)
    mainboard1.Gen()
    mainboard1.Save(dict(zip(['imA', 'imB', 'flowAB_viz'], name[0:3])))

    #    mainboard2 = Board([640, 480])
    #    mainboard2.addTrans(trans1_2)
    #    mainboard2.Gen()
    #    mainboard2.Save(dict(zip(['imB', 'flowAB_viz'],
    #                             name[3:])))
    print(f'完成:{i}/{num}')
print('全部完成!')