# Are four projected lines from a square?

I've detected a few lines in an image. Four of them are the edges of a square depicted in the image. The projective transformation of the camera has of course been applied to all the lines, making it impossible to use regular metrics such as straight angles and so on.

If I draw four randomly chosen lines from the attached image. Is there any way to decide whether those lines are the edges of a square?

-

Any set of four lines can represent the image of a square under a projective transform: Suppose your lines are $g_1$ through $g_4$. Let $P$ be the intersection of $g_1$ with $g_3$ and $Q$ be the intersection of $g_2$ with $g_4$. Then the line $\ell$ connecting $P$ and $Q$ will serve as the line at infinity. Any transformation which maps that line back to infinity will turn your quadrilateral into a parallelogram, a shear will turn that into a rectangle, and an anisotropic scale that into a square. All of the operations can be combined into a single projective transformation.