def solve_x3ds_normals(x2ds, splits, labels, Ps, rays, robust=True): x3ds, x3ds_labels, E, x2ds_labels = ISCV.solve_x3ds( x2ds, splits, labels, Ps, robust) x3ds_normals = np.ones_like(x3ds) for xi, label in enumerate(x3ds_labels): rayIndices = np.where(labels == label)[0] x3ds_normals[xi] = np.sum(rays[rayIndices], axis=0) # Normalise the ray directions x3ds_normals /= (np.sum(x3ds_normals * x3ds_normals, axis=1)**0.5).reshape(-1, 1) return x3ds, x3ds_labels, x3ds_normals, E, x2ds_labels
def solve_x3ds(x2ds, splits, labels, Ps, robust=True): """ Given some labelled 2d points, generate labelled 3d positions for every multiply-labelled point and equations for every single-labelled point. Args: x2ds (float[][2]): 2D Detections. splits (int[]): Indices of ranges of 2Ds per camera. labels (int[]: Labels of x2ds. Ps (?): Projection matrices of the cameras? robust (bool): Robustness Flag (requires more Rays to reconstruct). Default = True Returns: float[][3]: "x3ds" - the resulting 3D reconstructions. int[]: "x3d_labels" - the labels for the 3D points. ??: "E[singles]" - Equations describing 2D detections not born of the 3D yet. int[] "singles_labels" - labels for the 2D contributions. Requires: ISCV.solve_x3ds """ return ISCV.solve_x3ds( x2ds, splits, labels, Ps, robust) # x3ds, x3d_labels, E[single_rays], single_ray_labels