(znear, zfar, cx, cy, fl_x, fl_y, w, h)
| 98 | return P |
| 99 | |
| 100 | def 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 | |
| 120 | def fov2focal(fov, pixels): |
| 121 | return pixels / (2 * math.tan(fov / 2)) |
nothing calls this directly
no outgoing calls
no test coverage detected