-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to load the depth file from offline mode~ #17
Comments
Same question here. Help needed, thanks! |
Just refer this code which converts the nerfcapture raw data into the OpenCV coordinate: data_path = "/home/XXX/Folder"
camsinfo_json = os.path.join(data_path, "transforms.json")
with open(camsinfo_json, 'r') as file:
cams_info = json.load(file)
intrinsic = np.eye(4)
intrinsic[0, 0] = cams_info["fl_x"]
intrinsic[1, 1] = cams_info["fl_y"]
intrinsic[0, 2] = cams_info["cx"]
intrinsic[1, 2] = cams_info["cy"]
vis_meta = defaultdict(dict)
for frame, cams in enumerate(cams_info["frames"]):
c2w = np.array(cams["transform_matrix"])
c2w[2, :] *= -1
c2w = c2w[[1, 0, 2, 3], :]
c2w[0:3, 1:3] *= -1
vis_meta[frame]["c2w"] = c2w[:3]
vis_meta[frame]["intrinsics"] = intrinsic
vis_meta[frame]["cam_idx"] = 0
# rgb
rgb_file = os.path.join(data_path, "{0}.png".format(cams["file_path"]))
rgb = np.array(Image.open(rgb_file))
depth_file = os.path.join(data_path, cams["depth_path"])
depth = cv2.imread(depth_file, cv2.IMREAD_ANYDEPTH | cv2.IMREAD_GRAYSCALE)
depth = np.array(Image.fromarray(depth).resize((rgb.shape[1], rgb.shape[0]), Image.Resampling.NEAREST)) / 255.0
vis_meta[frame]["rgb"] = rgb
vis_meta[frame]["depth"] = depth |
Hi! Thanks for your fast reply and help! I just tried your code, then the depth will be between 0-1, in fact most values will be 1. For your dept data also in this way? |
i think it should be right even the result looks like not so optimal. I will use your suggested code to read the depth and check the result with splatam. |
Just refer to the nerfstudio data process |
cool I found it. Thanks a lot! |
Hi! have you solved the the problem of splaTAM reconstruction in offline mode? Can you tell me the idea? Thanks |
Hello author~ I use offline mode to collect the RGB-D information and try to load the depth file from the local file.
I use this code to load the "*.depth.png"
np.array(Image.open(depth_file).resize((rgb.shape[1], rgb.shape[0]), Image.Resampling.NEAREST))
and find it's a 4-channel array (Usually it should be 1-channel)
This is the depth file:
So I would like to ask for advice on how to properly load a depth file, thanks!
The text was updated successfully, but these errors were encountered: