From 44cb00e468472c5a927eea00a0bb61ef4a279199 Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Fri, 6 May 2022 04:12:51 -0700 Subject: [PATCH] lstsq fix in circle fitting for old PyTorch Summary: the pytorch3d.compat.lstsq function needs a 2D rhs. Reviewed By: patricklabatut Differential Revision: D36195826 fbshipit-source-id: 9dbafea2057035cc04973f56729dc97b47dcac83 --- pytorch3d/implicitron/tools/circle_fitting.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytorch3d/implicitron/tools/circle_fitting.py b/pytorch3d/implicitron/tools/circle_fitting.py index 092a8ee2..77e22608 100644 --- a/pytorch3d/implicitron/tools/circle_fitting.py +++ b/pytorch3d/implicitron/tools/circle_fitting.py @@ -106,9 +106,9 @@ def fit_circle_in_2d( n_provided = points2d.shape[0] if n_provided < 3: raise ValueError(f"{n_provided} points are not enough to determine a circle") - solution = lstsq(design, rhs) - center = solution[:2] / 2 - radius = torch.sqrt(solution[2] + (center ** 2).sum()) + solution = lstsq(design, rhs[:, None]) + center = solution[:2, 0] / 2 + radius = torch.sqrt(solution[2, 0] + (center ** 2).sum()) if n_points > 0: if angles is not None: warnings.warn("n_points ignored because angles provided")