3

Our core aim is:

  1. to use Image Processing to read/scan an architectural Floor Plan Image (exported from a CAD software)
  2. to use Image Processing to read/scan an architectural Floor Plan Image (exported from a CAD software) extract the various lines and curves, group them into Structural Entities like walls, columns, beams etc. – ‘Wall_01’, ‘Beam_03’ and so on
  3. extract the dimensions of each of these Entities based on the scale and the length of the lines in the Floor Plan Image (since AutoCAD lines are dimensionally accurate as per the specified Scale)
  4. and associate each of these Structural Entities (and their dimensions) with a ‘Room’.

We have flexibility in that we can define the exact shapes of the different Structural Entities in the Floor Plan Image (rectangles for doors, rectangles with hatch lines for windows etc.) and export them into a set of images for each Structural Entity (e.g. one image for walls, one for columns, one for doors etc.).

For point ‘B’ above, our current approach based on OpenCV is as follows:

  1. Export each Structural Entity into its own image
  2. Use Canny and HoughLine Transform to identify lines within the image
  3. Group these lines into individual Structural Elements (like ‘Wall_01’)

We have managed to detect/identify the line segments using Canny+HoughLine Transform with a reasonable amount of accuracy.

Original Floor Plan Image Original Floor Plan Image

Individual ‘Walls’ Image: Individual ‘Walls’ Image

Line Segments identified using Canny+HoughLine: Line Segments identified using Canny+HoughLine

(I don't have enough reputation to post images yet)

So the current question is - what is the best way to group these lines together into a logical Structural Entity like ‘Wall_01’?

Moreover, are there any specific OpenCV based techniques that can help us group the line segments into logical Entities? Are we approaching the problem correctly? Is there a better way to solve the problem?


Update: Adding another image of valid wall input image. Another valid wall input image

  • If you have access to CAD files and a CAD program that can read them, it seems like you could get much better accuracy by writing macros in your CAD program. If you do it in OpenCV, you're limited to pixel accuracy of a raster image. – bfris Jun 19 '18 at 18:15
  • @bfris [SDK options for reading DWG files](https://stackoverflow.com/questions/45591400/objectarx-realdwg-or-teigha) RealDWG is the only option if we want to create a standalone software. Otherwise we have to create AutoCAD plugins. RealDWG licensing is expensive and limited. Licensing issues that have been prevalent. [User problems & response issues](https://forums.autodesk.com/t5/net/realdwg-installer-why-so-cryptic/m-p/6341741#M48734) In general, Autodesk is not very responsive. I tried registering and searching on the dev portal and it was full of 404. – Dhawal Banker Jun 25 '18 at 08:01

2 Answers2

2

You mention "exported from a CAD software". If the export format is PDF, it contains vector data for all graphic elements. You might be better off trying to extract and interpret that. Seems a bit cumbersome to go from a vector format to a pixel format which you then try to bring back to a numerical model.

NUMENA
  • 21
  • 2
  • That's a good catch and suggestion. I am going to try pdf extraction [this](https://superuser.com/questions/302045/how-to-extract-vectors-from-a-pdf-file) and [this](http://smallbusiness.chron.com/extract-vector-graphic-pdf-47224.html). I will also check with the team if I have missed any reason why we are not processing PDF. I will also try and convert it into PostScript and see if that can make progress any easier. – Dhawal Banker Jun 26 '18 at 14:57
0

If you have clearly defined constraints as to what your walls, doors, etc will look like in your image, you would use exactly those. If you are generating the CAD exports yourself, modify the settings there so as to facilitate this

For instance, the doors are all brown and are closed figures.

Same for grouping the walls. In the figures, it looks like you can group based on proximity (i.e, anything within X pixels of each other is one group). Although, the walls to the right of the text 'C7' and below it may get grouped into one.


If you do not have clear definitions, you may be looking at some generic image recognition problems, which means A.I or Machine Learning. This would require a large variety of inputs for it to learn from, and may get very complex

Aswin B
  • 1
  • 1
  • Not grouping nearby walls is the main problem. Let's assume we have found the relevant line segments. Given this, how can we find which 3 or 4 lines are part of one continuous wall? Once we figure this, next step would be to find the dimension for each of those walls. – Dhawal Banker Jun 25 '18 at 08:07
  • Okay, now on the assumption that all connected black lines are guaranteed to be part of one wall, and one wall only, consider the topmost black line (above text 'C8'). Is this wall bounded by the upper brown line, or the lower one? Do you have some way to differentiate? If you don't, and it's not because you don't care either way, I don't think you can solve this with image processing. As @bfris suggested, you'll need to look into the CAD side of this. If you don't care, how about having the OpenCV script search along non-white lines from one end of a black line, to the other? – Aswin B Jun 25 '18 at 13:48
  • "Individual ‘Walls’ Image" is the extraction of only walls layer from original layout image. I have updated the question with another input image as well. So, connected black lines may or may not be part of the same wall. – Dhawal Banker Jun 25 '18 at 14:23