Rect detection