Ejemplo n.º 1
0
        else:
            os.mkdir(writedir)

        writedirjason = jasondirname + '/apartment_' + str(env_id) + '/'
        if os.path.exists(writedirjason):
            print('folder already exists')
        else:
            os.mkdir(writedirjason)

        # start simulation (only once for each apartment)
        comm = UnityCommunication()
        comm.reset(env_id)
        #comm.setBathroomTexture(env_id)
        #wantedgraph = pickle.load( open( graphdirname + '/apartment_' + str(env_id) + ".pkl", "rb" ) )
        #print(wantedgraph)
        _, message = comm.expand_scene(wantedgraph)

        #============================ START PYTHON SCRIPT ===========================
        res, origraph = comm.environment_graph()
        target_id = node['id']  #target object to recognize
        targetclassname = node['class_name']
        targetprefabname = node['prefab_name']

        if targetclassname not in wantedClass:
            continue

        print('Processing prefab id: ' + str(target_id))
        targetroomname = find_rooms(origraph, node)
        targetroombbox = find_nodes_byclassname(
            origraph, targetroomname)[0]['bounding_box']
        avgtargetsize = np.mean(node['bounding_box']['size'])
Ejemplo n.º 2
0
SurfaceList = wanted['SurfaceList']
wantedClass = wanted['wantedClass']

for target_classname in wantedClass:   

    for env_id in range(7): # env_id ranges from 0 to 6   
    
        # start simulation (only once for each apartment)
        comm = UnityCommunication()
        comm.reset(env_id)
        #comm.setBathroomTexture(env_id)
        
        #============================ START PYTHON SCRIPT ===========================
        response, origraph = comm.environment_graph()
        origraph = deleteGraphByClassname(origraph, target_classname) 
        success, message = comm.expand_scene(origraph)
        #print(origraph)
        #exit()
        #loop through all nodes and check whether we have wanted
        DestIds, DestPrefabs, destRooms, destSurface = findAllPossibleDestNodes(target_classname, wantedClass, ItemToRoom, SurfaceToRoom, RoomList, SurfaceList, origraph) 
         
        #loop through missed classes
        #randomly sample prefab from it and add to the graph        
        for i, destid in enumerate(DestIds):
            
            newIDs = 1000 #fixed; dont change; always starts from 1000 and onwards
            comm.reset(env_id)
            response, origraph = comm.environment_graph()    
            #print(origraph)
            
            #get ready to add new object belonging to current class