(args, id, cam_info, resolution_scale)
| 17 | WARNED = False |
| 18 | |
| 19 | def loadCam(args, id, cam_info, resolution_scale): |
| 20 | orig_w, orig_h = cam_info.width, cam_info.height# cam_info.image.size |
| 21 | |
| 22 | if args.resolution in [1, 2, 3, 4, 8]: |
| 23 | resolution = round(orig_w/(resolution_scale * args.resolution)), round(orig_h/(resolution_scale * args.resolution)) |
| 24 | scale = resolution_scale * args.resolution |
| 25 | else: # should be a type that converts to float |
| 26 | if args.resolution == -1: |
| 27 | if orig_w > 1600: |
| 28 | global WARNED |
| 29 | if not WARNED: |
| 30 | print("[ INFO ] Encountered quite large input images (>1.6K pixels width), rescaling to 1.6K.\n " |
| 31 | "If this is not desired, please explicitly specify '--resolution/-r' as 1") |
| 32 | WARNED = True |
| 33 | global_down = orig_w / 1600 |
| 34 | else: |
| 35 | global_down = 1 |
| 36 | else: |
| 37 | global_down = orig_w / args.resolution |
| 38 | |
| 39 | scale = float(global_down) * float(resolution_scale) |
| 40 | resolution = (int(orig_w / scale), int(orig_h / scale)) |
| 41 | |
| 42 | cx = cam_info.cx / scale |
| 43 | cy = cam_info.cy / scale |
| 44 | fl_y = cam_info.fl_y / scale |
| 45 | fl_x = cam_info.fl_x / scale |
| 46 | |
| 47 | loaded_mask = None |
| 48 | if not args.dataloader: |
| 49 | resized_image_rgb = PILtoTorch(cam_info.image, resolution) |
| 50 | gt_image = resized_image_rgb[:3, ...] |
| 51 | |
| 52 | if resized_image_rgb.shape[0] == 4: |
| 53 | loaded_mask = resized_image_rgb[3:4, ...] |
| 54 | else: |
| 55 | gt_image = cam_info.image |
| 56 | |
| 57 | if cam_info.depth is not None: |
| 58 | depth = PILtoTorch(cam_info.depth, resolution) * 255 / 10000 |
| 59 | else: |
| 60 | depth = None |
| 61 | |
| 62 | return Camera(colmap_id=cam_info.uid, R=cam_info.R, T=cam_info.T, |
| 63 | FoVx=cam_info.FovX, FoVy=cam_info.FovY, |
| 64 | image=gt_image, gt_alpha_mask=loaded_mask, |
| 65 | image_name=cam_info.image_name, uid=id, data_device=args.data_device, |
| 66 | timestamp=cam_info.timestamp, |
| 67 | cx=cx, cy=cy, fl_x=fl_x, fl_y=fl_y, depth=depth, resolution=resolution, image_path=cam_info.image_path, |
| 68 | meta_only=args.dataloader |
| 69 | ) |
| 70 | |
| 71 | def cameraList_from_camInfos(cam_infos, resolution_scale, args): |
| 72 | camera_list = [] |
no test coverage detected