|
radial_distortion = np.array([K1, K2]).reshape(-1,) |
Current code:
radial_distortion = np.array([K1, K2]).reshape(-1,)
Proposed replacement:
radial_distortion = np.array([K1, K2]).ravel()
Both reshape(-1,) and ravel() flatten arrays into 1-D.
Performance: ravel() is consistently faster than reshape(-1,), as it avoids extra shape compatibility checks.
Robustness: ravel() directly returns a view when possible, and only falls back to a copy if required, whereas reshape(-1,) requires the array to be contiguous.
TEMPEH/utils/camera.py
Line 79 in 90cc1e5
Current code:
radial_distortion = np.array([K1, K2]).reshape(-1,)Proposed replacement:
radial_distortion = np.array([K1, K2]).ravel()Both reshape(-1,) and ravel() flatten arrays into 1-D.
Performance: ravel() is consistently faster than reshape(-1,), as it avoids extra shape compatibility checks.
Robustness: ravel() directly returns a view when possible, and only falls back to a copy if required, whereas reshape(-1,) requires the array to be contiguous.