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

Function loadCam

utils/camera_utils.py:21–54  ·  view source on GitHub ↗
(args, id, cam_info, resolution_scale)

Source from the content-addressed store, hash-verified

19WARNED = False
20
21def loadCam(args, id, cam_info, resolution_scale):
22 orig_w, orig_h = cam_info.image.size
23
24 if args.resolution in [1, 2, 4, 8]:
25 resolution = round(orig_w/(resolution_scale * args.resolution)), round(orig_h/(resolution_scale * args.resolution))
26 else: # should be a type that converts to float
27 if args.resolution == -1:
28 if orig_w > 1600:
29 global WARNED
30 if not WARNED:
31 print("[ INFO ] Encountered quite large input images (>1.6K pixels width), rescaling to 1.6K.\n "
32 "If this is not desired, please explicitly specify '--resolution/-r' as 1")
33 WARNED = True
34 global_down = orig_w / 1600
35 else:
36 global_down = 1
37 else:
38 global_down = orig_w / args.resolution
39
40 scale = float(global_down) * float(resolution_scale)
41 resolution = (int(orig_w / scale), int(orig_h / scale))
42
43 resized_image_rgb = PILtoTorch(cam_info.image, resolution)
44
45 gt_image = resized_image_rgb[:3, ...]
46 loaded_mask = None
47
48 if resized_image_rgb.shape[1] == 4:
49 loaded_mask = resized_image_rgb[3:4, ...]
50
51 return Camera(colmap_id=cam_info.uid, R=cam_info.R, T=cam_info.T,
52 FoVx=cam_info.FovX, FoVy=cam_info.FovY,
53 image=gt_image, gt_alpha_mask=loaded_mask,
54 image_name=cam_info.image_name, uid=id, data_device=args.data_device)
55
56
57def cameraList_from_camInfos(cam_infos, resolution_scale, args):

Callers 1

cameraList_from_camInfosFunction · 0.85

Calls 2

PILtoTorchFunction · 0.90
CameraClass · 0.90

Tested by

no test coverage detected