1
$\begingroup$

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?

Depicted lines

$\endgroup$
  • $\begingroup$ Every set of four lines apparently can form a square in two different ways and also an infinite number of rectangles. In practical applications there must be some way to rule out ones that mathematically involve viewing from near infinity or at an extremely wide angle. For example when a 1x1 square maps to a 2x1 rectangle that's mathematically possible but won't happen in practical applications. This is where I'm stuck though. $\endgroup$ – hippietrail Aug 24 '17 at 2:38
3
$\begingroup$

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.

You might be able to rule out some combinatuons, where a line segment passes past a corner of the assumed suqare, but other than that, you simply have too little information.

$\endgroup$
2
$\begingroup$

In this answer and its referenced answer it is shown that any convex quadrilateral can represent a square under a perspective projection. If the quadrilateral is not convex, the edges are virtual projections from behind the plane of the viewer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.