MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / loadCamv2timing

Function loadCamv2timing

examples/helper/STG/camera_utils.py:126–167  ·  view source on GitHub ↗
(args, id, cam_info, resolution_scale)

Source from the content-addressed store, hash-verified

124
125
126def loadCamv2timing(args, id, cam_info, resolution_scale):
127 orig_w, orig_h = cam_info.image.size
128
129 if args.downscale_factor in [1, 2, 4, 8]:
130 resolution = round(orig_w/(resolution_scale * args.downscale_factor)), round(orig_h/(resolution_scale * args.downscale_factor))
131 else: # should be a type that converts to float
132 if args.downscale_factor == -1:
133 if orig_w > 1600:
134 global WARNED
135 if not WARNED:
136 print("[ INFO ] Encountered quite large input images (>1.6K pixels width), rescaling to 1.6K.\n "
137 "If this is not desired, please explicitly specify '--resolution/-r' as 1")
138 WARNED = True
139 global_down = orig_w / 1600
140 else:
141 global_down = 1
142 else:
143 global_down = orig_w / args.downscale_factor
144
145 scale = float(global_down) * float(resolution_scale)
146 resolution = (int(orig_w / scale), int(orig_h / scale))
147
148 resized_image_rgb = PILtoTorch(cam_info.image, resolution)
149
150 gt_image = resized_image_rgb[:3, ...]
151 loaded_mask = None
152
153 if resized_image_rgb.shape[1] == 4:
154 loaded_mask = resized_image_rgb[3:4, ...]
155
156 cameradirect = cam_info.hpdirecitons
157 camerapose = cam_info.pose
158
159 if camerapose is not None:
160 rays_o, rays_d = 1, cameradirect
161 else :
162 rays_o = None
163 rays_d = None
164 return Camera(colmap_id=cam_info.uid, R=cam_info.R, T=cam_info.T,
165 FoVx=cam_info.FovX, FoVy=cam_info.FovY,
166 image=gt_image, gt_alpha_mask=loaded_mask,
167 image_name=cam_info.image_name, uid=id, data_device=args.data_device, near=cam_info.near, far=cam_info.far, timestamp=cam_info.timestamp, rayo=rays_o, rayd=rays_d,cxr=cam_info.cxr,cyr=cam_info.cyr)
168
169
170

Callers

nothing calls this directly

Calls 2

PILtoTorchFunction · 0.85
CameraClass · 0.85

Tested by

no test coverage detected