A tool box for RPLAN dataset.
-
Install dependency
-
python>=3.7
-
matlab (for alignment): Install MATLAB Engine API for Python
-
numpy, scipy, scikit-image, matplotlib
-
shapely (for visualization)
-
faiss (Linux only, for clustering)
-
-
Load a floorplan
RPLAN_DIR = './data'
file_path = f'{RPLAN_DIR}/0.png'
fp = Floorplan(file_path)
img = fp.image
- Get image channels
fp.boundary
fp.category
fp.instance
fp.inside
- Get vector graphics information
data = fp.to_dict()
print(data.keys())
- Align rooms with boundary, neighbors
from rplan.align import align_fp_gt
boxes_aligned, order, room_boundaries = align_fp_gt(data['boundary'],data['boxes'],data['types'],data['edges'])
data['boxes_aligned'] = boxes_aligned
data['order'] = order
data['room_boundaries'] = room_boundaries
- Add doors and windows for a vector floorplan
from rplan.decorate import get_dw
doors,windows = get_dw(data)
data['doors'] = doors
data['windows'] = windows
- Plot floorplan
from rplan.plot import get_figure,get_axes
from rplan.plot import plot_category,plot_boundary,plot_graph,plot_fp
plot_category(fp.category) # raw image
plot_boundary(data['boundary']) # vector boundary
plot_graph(data['boundary'],data['boxes'],data['types'],data['edges']) # node graph
plot_fp(data['boundary'], data['boxes_aligned'][order], data['types'][order]) # vector floorplan
plot_fp(data['boundary'], data['boxes_aligned'][order], data['types'][order],data['doors'],data['windows']) # vector floorplan with doors and windows
- Get the turning function for a boundary
from rplan.measure import compute_tf
from rplan.plot import plot_tf
x,y = compute_tf(data['boundary'])
plot_tf(x,y)
-
Cluster turning functions: See
cluster_tf.py
. Linux system and FAISS are required. -
Retrieve based on the turning function
import numpy as np
from rplan.measure import TFRetriever
tf = np.load('output/tf_discrete.npy')
tf_centroids = np.load('output/tf_centroids.npy')
tf_clusters = np.load('output/tf_clusters.npy')
retriever = TFRetriver(tf,tf_centroids,tf_clusters)
top_20 = retriever.retrieve_cluster(data['boundary'],k=20,beam_search=True) # Knn search
top_5 = retriever.retrieve_bf(data['boundary'],k=5) # argsort