Automatic perspective correction for quadrilateral objects