MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / align_pose

Function align_pose

utils/sfm_utils.py:464–493  ·  view source on GitHub ↗
(pose1, pose2)

Source from the content-addressed store, hash-verified

462 return renders, gts, image_names
463
464def align_pose(pose1, pose2):
465 mtx1 = np.array(pose1, dtype=np.double, copy=True)
466 mtx2 = np.array(pose2, dtype=np.double, copy=True)
467
468 if mtx1.ndim != 2 or mtx2.ndim != 2:
469 raise ValueError("Input matrices must be two-dimensional")
470 if mtx1.shape != mtx2.shape:
471 raise ValueError("Input matrices must be of same shape")
472 if mtx1.size == 0:
473 raise ValueError("Input matrices must be >0 rows and >0 cols")
474
475 # translate all the data to the origin
476 mtx1 -= np.mean(mtx1, 0)
477 mtx2 -= np.mean(mtx2, 0)
478
479 norm1 = np.linalg.norm(mtx1)
480 norm2 = np.linalg.norm(mtx2)
481
482 if norm1 == 0 or norm2 == 0:
483 raise ValueError("Input matrices must contain >1 unique points")
484
485 # change scaling of data (in rows) such that trace(mtx*mtx') = 1
486 mtx1 /= norm1
487 mtx2 /= norm2
488
489 # transform mtx2 to minimize disparity
490 R, s = scipy.linalg.orthogonal_procrustes(mtx1, mtx2)
491 mtx2 = mtx2 * s
492
493 return mtx1, mtx2, R
494
495def storePly(path, xyz, rgb):
496 # Define the dtype for the structured array

Callers 1

evaluateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected