my plan is to extract information out of a floor plan drawn on a paper. I already managed to detect 70-80% of the drawn doors:
Now I want to create a data model from the walls. I already managed to extract them as you can see here:
From that I created the contours:
My idea now was to get the intersections of the lines from that image and create a data model from that. However if I use houghlines algorithm I get something like this:
Does somebody have a different idea of how to get the intersections or even another idea how to get a model? Would be very nice.
PS: I am using javacv. But an algorithm in opencv would also be alright as I could translate that.
It strikes me that what you really want is not necessarily walls, but rather rooms - which are incidentally bounded by walls.
Moreover, while it looks like your "wall" data is rather noisy (i.e. there are lots of small sections that could be confused for tiny rooms) - but your "room" data isn't (there aren't many phantom walls in the middle of rooms).
Therefore, it may be beneficial to detect rooms (approximately axis-aligned rectangles that don't contain white pixels over a certain threshold), and extrapolate walls by looking at the boundary between nearby pixels.
I would implement this in three phases: first, try to detect a few principle axis from the output of houghlines (I would first reach for a K-means clustering algorithm, and then massage the output to get perpendicular axis). Use this data to better align the image.
Second, begin seeding small rectangles randomly about the image, in black areas. "Grow" these rectangles in all directions until each side hits a white pixel over a certain threshold, or they run into another rectangle. Continue seeding until a large percentage of the area of the image is covered.
Third, find areas (also rectangles, hopefully) not covered by rectangles, and collapse them into lines:
There are a few drawbacks to this approach:
I apologize for not including any code snippets - but I thought it more important to convey the idea, rather than the details (please comment if you'd like me to expand on any of it). Also note, that while I played around with opencv a few years ago, I'm by no means an expert - so it may already have some primitives to do some of this for you.