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. 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
You should try to find the vanishing point of the structural lines of the room. There are many line-finding algorithms for this.
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:
To map a texture on the floor, you just have to find the bounding rectangle following the tiling:
来源:https://stackoverflow.com/questions/38991858/finding-the-angle-of-a-perspective-image