obj1_datamask = RectArray(obj1_rect, 1, dtype=np.bool) obj1_datamask.SetValue(immask) # #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_opts = GetTransOpts() trans_opts['xz_theta'] = func.RandomAngle(np.pi / 2) trans_opts['py'] = func.RandomDis((-100, -100), (100, 100)) trans.GenTrans('py', trans_opts) trans.GenTrans('xz', trans_opts) trans.ImposeTrans() #DisplayObject(obj1) mainboard = Board([640, 480]) mainboard.addTrans(trans) mainboard.Gen() mainboard.Save({'imA': '../data/ds_v2/TEST2/1A.jpg'}) mainboard.Save({'imB': '../data/ds_v2/TEST2/1B.jpg'}) mainboard.Save({'flowA_viz': '../data/ds_v2/TEST2/1gt.jpg'}) look = mainboard.Save({'flowA': '../data/ds_v2/TEST2/1gt.flo'}) #print(obj1)
##################################### # 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) ###############################################
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) # 通过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]