Detecting Perspective Angle

Hi,
I’m trying to replace texture of a floor, I’m successfully able to to detect the floor and replace it with new texture but I’m unable to match the perspective angle of new floor.
currently I’m manually setting the perspective angle.
Is there any way to automatically detect the perspective angle of image ? I’ve been thinking about using vanishing point but not succeeded uptill now.

I have the floor mask, just need to detect the perspective angle of it:

1 Like

any update on this?
By the way which method did you use to get such good results?