Using OpenCV Canny edge detection and Hough line transform to detect lines in an image, then use A* to search line intersections for rectangular shapes.