MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / getProjectionMatrixCenterShift

Function getProjectionMatrixCenterShift

utils/graphics_utils.py:100–118  ·  view source on GitHub ↗
(znear, zfar, cx, cy, fl_x, fl_y, w, h)

Source from the content-addressed store, hash-verified

98 return P
99
100def getProjectionMatrixCenterShift(znear, zfar, cx, cy, fl_x, fl_y, w, h):
101 top = cy / fl_y * znear
102 bottom = -(h-cy) / fl_y * znear
103
104 left = -(w-cx) / fl_x * znear
105 right = cx / fl_x * znear
106
107 P = torch.zeros(4, 4)
108
109 z_sign = 1.0
110
111 P[0, 0] = 2.0 * znear / (right - left)
112 P[1, 1] = 2.0 * znear / (top - bottom)
113 P[0, 2] = (right + left) / (right - left)
114 P[1, 2] = (top + bottom) / (top - bottom)
115 P[3, 2] = z_sign
116 P[2, 2] = z_sign * zfar / (zfar - znear)
117 P[2, 3] = -(zfar * znear) / (zfar - znear)
118 return P
119
120def fov2focal(fov, pixels):
121 return pixels / (2 * math.tan(fov / 2))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected