/FloorplanToBlender3d

Create 3d rooms in blender from floorplans.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

powerpoint

Table of Contents (click to expand)

About

The virtualisation of real life objects has been a hot topic for several years. As I started learning about 3d modelling in Blender3d I thought of the idea to use simple imaging on floorplans to automatically create corresponding 3d models. It is much easier than it sounds and uses a low amount of resources, enabling it to be used on low hardware. By utilizing Blender3d, all created objects will be easy to transfer to any other 3d rendering program. Such as Unity, Unreal Engine or CAD.

How-To

This part contains information about how to setup and execute this program.

NOTE: Using other versions of the required programs and libraries than specified in this file might require changes in the implementation. It is only guaranteed that this implementation will work if the assigned versions of all requirements are used. At this time it is known that:

  • If a later Blender version is used, several changes has to done in all files in the /Blender folder.
  • If the latest OpenCV library for python is used, several changes has to be done in the /FloorplanToBlender3d/detect.py file. Please create an issue if you encounter any problems with this implementation.

NOTE: To avoid any version related problems use the Docker implementation.

Install on Docker

Firstly you need to install a suitable Docker environment on your device. This project contains a DockerFile which uses the Ubuntu 18.04 image so make sure your docker environment is set to linux containers.

  1. Download or clone this repository.

  2. Build docker image from DockerFile by running: NOTE: This step can take a long time.

 docker build . --tag=floorplan_to_blender:1.0
  1. To start the image run:
 docker run -it floorplan_to_blender:1.0 bash

This will take you into your virtual environment where you can safely test the implementation.

  1. To run the program, enter the container and run:
  python3 create_blender_project_from_floorplan.py

Blender is installed on path /usr/local/blender/blender, the path can be changed in the config.ini file with nano inside the container. The generated .blender file can be retreived with scp or using volumes.

  1. Some useful docker commands:
  # Get into a running container
 docker exec -it container_name bash

 # Stop all containers
 docker rm -f $(docker ps -aq)

 # Remove all images
 docker rmi $(docker images)

Install on OS

This tutorial will describe how to install this implementation directly on your device. If you are a Linux/Ubuntu user, look at DockerFile for better instructions.

These are the programs that are required to run this implementation.

If you have Python3 pip installed you can install required packages by running:

 pip install -r requirements.txt

Or install them manually by running :

pip install

  • opencv-python==3.4.1.15 (OpenCV)
  • numpy==1.16.2
  • configparser==3.5.0
  • future-fstrings==1.2.0
  • imutils==0.5.2
  • pyfiglet==0.7.6

Clone or download this repo:

git clone https://github.com/grebtsew/FloorplanToBlender3d.git

Run

This tutorial takes you through the execution of this program.

  1. Receive floorplan as image, from pdf or by using other method (for example paint)
  2. Run python script create_blender_project_from_floorplan.py
  3. Follow instructions

Run (Old but still working!)

This tutorial takes you through the execution of this program in examples.

  1. Receive floorplan as image, from pdf or by using other method (for example paint)
  2. Set image file path in Examples/floorplan_to_datafile.py
  3. Run ´floorplan_to_datafile.py´ to create data files for your floorplan.
  4. Edit path in floorplan_to_datafile.py to generated data files.
  5. Start blender
  6. Open Blender text editor
  7. Open floorplan_to_3dObject_in_blender.py in blender by pressing the text editor, then alt+o and find the file
  8. Run script

Demo

Here we demo the program. First of we need a floorplan image to process. We use example.png, see below: Floorplanexample

Next up we execute our script and answer the questions: gif1

Finally we can open the newly created floorplan.blender file and see the result: gif2

Note: This demo only uses default settings. For instance coloring is by default random.

Testing

Vital and core functionality are tested with pytest. To run tests yourself enter "Testing"-folder and run:

pytest

References and Imports

During the development of this project I have been searching alot and copied code from StackOverflow. I share links to copied code and other contributors here:

Contribute

Let me know if you want to contribute to this project, also if you want me to add more functions or answer questions, let me know!

Known Issues

These are some known issues with the current implementation:

  • Floorplan images needs to be quite small for detections to work at this time. If you plan on using a large image, consider downscaling it.
  • Required programs and libraries might change in future versions, this might require some changes in this implementation for it to work. If you insist on not using the versions specified in this Readme file, a coding effort might be required.

License

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007

COPYRIGHT @ Grebtsew 2019