I am looking for a fast idea/algorithm letting me to find squares (as mark points) in the image file. It shouldn't be so much challenge, however...

I started doing this by changing the color of the source image to a grey scale image and scanning each line of the image looking for two, three longest lines (pixel by pixel).

Then having an array of "lines" I am finding elements which may create the desire square.

The better idea would be to find the pattern with known traits, like: it is square, beyond of the square there are no distortion (there is just white space) etc.

The goal is to analyze the image 5000 X 5000 px in less than 1-2s.

Is it possible?