1

The purpose of this program is to map out the corners and edges of a room, here is where I'm at right now: image_current The image on the top right is my result, and the image on the top left is my input. Currently, I am using canny edge detection with a gaussian filter. But as you can see, there are a lot of random lines coming from other details in the image.

My goal is this: image_result

So far, I've tried, Only showing lines that are flat (0 or infinite slope):

if lines is not None:
    for line in lines:
        x1, y1, x2, y2 = line[0]
        if math.isclose(x1, x2, tol_abs=25) or math.isclose(y1, y2, tol_abs=10):
            cv2.line(bgrimg, (x1, y1), (x2, y2), (0, 255, 0), 1)

But this resulted in me losing some of the important lines. Next, I tried to only show lines on the edges of the image:

if lines is not None:
    for line in lines:
        x1, y1, x2, y2 = line[0]
        if y1 > 100 and y2 > 100:
            cv2.line(bgrimg, (x1, y1), (x2, y2), (0, 255, 0), 1)

This somewhat works for the top, but since the sides could be anywhere in the picture, I can't determine exactly where they will be.

Is there a way to solve this? If not, would it be possible with machine learning?

Rithwik Babu
  • 104
  • 1
  • 6
  • I think the major problem are the shadows in the walls . You can try to adjust contrast of the images. But at the end the better way is manually set the corners teaching the software how recognize when are important when not. May be rooms are all similar . Are boxes . Find the upper corners then vertical lines are consequence of it . – Mario Abbruscato Apr 08 '21 at 18:04

1 Answers1

0

Starting from the information obtained by Canny. Could:

1 - Determine a good reference for the horizontal line,

2 - Determine a good reference for the right diagonal line

3 - Determine a good reference for the left diagonal line

4 - From the extension of these reference lines you can find the intersections.

Some intersections will be good, others bad.

It is a good intersection if the angle formed by the horizontal reference line and the oblique reference line are the same or similar both to the right and to the left.

As in the image I added here: https://i.stack.imgur.com/OYS2c.png

Mario Abbruscato
  • 819
  • 1
  • 7
  • 9