Turn a 2D floorplan image into a 3D model (.obj / .stl) you can open in any 3D viewer or slicer.
The working pipeline is built around a deep-learning floorplan parser (CubiCasa5K) that understands walls and rooms, plus a small set of scripts that extrude the detected geometry into clean 3D. A classical OpenCV route (FloorplanToBlender3d, via Docker) is kept as a fallback. Everything runs locally on CPU — no GPU required.
| Floorplan | Detection overlay | 3D model |
|---|---|---|
| Unit C1 | ![]() |
![]() |
| 2d-model | ![]() |
![]() |
The overlay (detected walls/rooms drawn on the source) is the accuracy check; the 3D is the extruded model.
Outputs live in Target/ — .obj, .stl, and preview PNGs.
The CubiCasa model + weights + venv are heavy and git-ignored — set them up once via SETUP_CUBICASA.md. Then, for any floorplan image:
# 1) segment walls/rooms (neural net, CPU ~2 min) -> saves *_vectors.pkl + *_overlay.png
cd cubicasa/CubiCasa5k
../.venv/bin/python cubi_infer.py <image> out/<name> 1024
cd ../..
# 2) extrude the clean vector geometry into a connected 3D wall shell + room floors
cubicasa/.venv/bin/python poly_to_obj.py cubicasa/CubiCasa5k/out/<name>_vectors.pkl Target/<name>.obj
# 3) convert to STL (pure Python, no deps)
python3 obj_to_stl.py Target/<name>.obj Target/<name>.stlScripts
cubi_infer.py— CubiCasa inference on one image → room/wall segmentation, clean vector geometry (*_vectors.pkl), and a diagnostic overlay. (Run from inside the CubiCasa5k clone; see SETUP.)poly_to_obj.py— extrudes the vector geometry: unions wall rectangles into one connected shell (seamless corners, capped top/bottom) and builds per-room floor slabs.obj_to_stl.py— Wavefront OBJ → binary STL (triangulates faces).render_obj.py— quick matplotlib preview of an OBJ.
The original OpenCV route works via the upstream prebuilt image (its bundled Blender crashes under x86
emulation on Apple Silicon, so floorplan_to_obj.py exports geometry directly, skipping Blender):
docker build --platform linux/amd64 -f Dockerfile.patch -t ftb-patched .
docker run --rm --platform linux/amd64 \
-v "$PWD/floorplan_to_obj.py":/home/floorplan_to_blender/floorplan_to_obj.py \
-v "$PWD/your.jpg":/home/floorplan_to_blender/Images/your.jpg \
-v "$PWD/Target":/home/floorplan_to_blender/Target \
-w /home/floorplan_to_blender --entrypoint python3.8 ftb-patched \
floorplan_to_obj.py --walls-only Images/your.jpg Target/your.objResults are far rougher than the CubiCasa pipeline — kept only for reference.
- CPU inference takes a couple of minutes per image.
- Scale is proportional, not metric (no automatic real-world dimensions yet).
- Doorways aren't cut — CubiCasa reports 0 door/window openings on these arc-style plans, so walls stay
continuous.
poly_to_obj.pysubtracts openings automatically whenever the model does detect them. - Detection quality depends on input resolution (~800–1024px works best) and a reasonably clean floorplan.
Parth Bhandakkar – B.Tech ECE @ IIIT Naya Raipur — GitHub Srijan Ratrey – B.Tech AI/DS @ IIIT Naya Raipur — GitHub
MIT License – see LICENSE file for details.
Model: CubiCasa5K (Kalervo et al., 2019). Classical route: FloorplanToBlender3d.



