grebtsew / FloorplanToBlender3d

Create 3d rooms in blender from floorplans.
GNU General Public License v3.0
396 stars 103 forks source link

Some walls not showing on the output has been fixed #20

Closed frankkim1108 closed 2 years ago

frankkim1108 commented 2 years ago

The code shown in the remove_walls_not_int_contour is using cv2.pointPolygonTest() to see if the wall is inside the outer contour or not. However, some floorplan's outer contour was too tight for the wall bounding rectangle box that it detected some walls as if it was outside of the outer contour.

So one way I tried fixing this issue was instead of doing a pointPolygonTest with a outer contour of the house , which is an output from

# detect contour
contour, _ = detect.outer_contours(gray)

I tried it with a bounding rectangle box of a outer contour of a house.

the code below is what I did.

# detect contour
contour, _ = detect.outer_contours(gray)

(x, y, w, h) = cv2.boundingRect(contour)
p1 = [x, y]
p2 = [x, y + h]
p3 = [x + w, y + h]
p4 = [x + w, y]
pts = np.array([p1, p2, p3, p4], np.int32)
pts = pts.reshape(-1, 1, 2)

# remove walls outside of contour
boxes = calculate.remove_walls_not_in_contour(boxes, pts)
frankkim1108 commented 2 years ago

I'll fix my code a little bit more and request a pull request later