Floorplan image to 3D model
Part of the Home Health Monitor: turn an architectural floorplan image into walls, rooms and floors with OpenCV, then build a 3D model and CAD export with Blender's Python API.
Problem
The Home Health Monitor surveys a home room by room, and a survey is far more useful when it sits on a model of the building. Most homes have at best a floorplan image, drawn in any of a dozen styles, covered in labels, dimensions and furniture. Turning that into geometry was manual. This was one of Q-Bot’s UK innovation grant projects, alongside the device’s sensor calibration.
What I did
I built the pipeline from floorplan image to 3D model. With OpenCV, it first strips text, dimension lines and other annotation using morphology and connected components, keeping only what looks like structure. It segments the walls, simplifies their contours into polygons, and detects the floor outline. To find rooms, it uses Harris corners to close doorways with short line segments, then splits the plan into connected regions. Walls, floors and rooms are written out as vertices and faces.
Blender’s Python API then builds the model: walls extruded to height, floors and rooms as meshes, run headless from Python so one command goes from image to .blend and on to CAD formats.
To make it robust to the variety of real plans, I trained a deep CNN for floorplan feature extraction that also models spatial relationships between elements. And to close the loop from 3D scans back to plans, I extracted geometry features from point clouds to generate simple floorplan images, and began exploring end-to-end training from RGB-D scans to architecture-style floorplans.
Result
A working image-to-model pipeline. The video walks one plan through all six stages, then runs more plans, from a Japanese apartment to UK flats, from image straight to 3D model. End-to-end learning from RGB-D scans was in progress when I left.
figures
click to enlarge