Add the new algorithm for detect rectangle.