4

I'm working on a floor design app that allows the user to pick preset floor images and view them within a preset room image. enter image description here enter image description here My problem is I'm struggling to get the perspective of the floor image to match the room image properly. I have played around with setting the height of the viewpoint and the tilt but is there a way to calculate what these should be by using the real world measurements of the floor and room image? My knowledge in perspective drawing is very limited so I apologise if I'm using the wrong terminology. Any help or advice would be appreciated.

Thanks

hippietrail
  • 15,848
  • 18
  • 99
  • 158
WagglyWonga
  • 341
  • 3
  • 14

1 Answers1

8

You should try to find the vanishing point of the structural lines of the room. There are many line-finding algorithms for this.

Vanishing directions You have to find two vanishing points, for the two main directions of the floor. On your example, one vanishing point is at the convergence of all red lines, the other one is far on the left side, at the convergence of he blue lines.

Once you have this, you can build a regular tiling starting from these two points: Not so regular tiling

To map a texture on the floor, you just have to find the bounding rectangle following the tiling: enter image description here

to stretch your texture inside it: enter image description here

and to remove extra parts and apply shadows: enter image description here

Community
  • 1
  • 1
Gwen
  • 1,436
  • 3
  • 23
  • 31
  • 1
    Wow that's amazing, thanks for your speedy response and detailed answer. I now know what I need to do, just need to work on automating the process now. Thank you – WagglyWonga Aug 17 '16 at 10:22
  • 1
    Just a note that the problem might be a bit trickier than it looks. What you find is that you have an over-determined problem. Any pair of lines will give you a point of intersection. You will probably have multiple pairs of lies each giving a slightly different vanishing point. In the Computer Vision literature this has been given quite a bit of attention. – Salix alba Aug 17 '16 at 21:22
  • How did you apply the shadows in the last step? – Денис Степанов Aug 03 '21 at 14:10
  • If I remember correctly, I just applied a brightness correction factor from the original floor (you can notice the white line at the bottom of the picture is still visible on the result). – Gwen Aug 04 '21 at 18:07