-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Help] Getting the depth of the image plane #47
Comments
I think what you mean by the "depth of the image plane" is the distance from the camera center to the image plane. This distance is referred to as the focal length, and there are two types of focal length representations: focal length in pixels and physical focal length in metric space. TLDR: Typically, the focal length is expressed in pixels in computer vision, as specified in the intrinsic camera matrix Let's break it down. Assuming you have camera intrinsic
Where:
|
If you want to project depth images to 3D as point clouds, you may use the functions in import open3d as o3d
import camtools as ct
import json
import numpy as np
from pathlib import Path
def main():
# Get paths.
redwood = o3d.data.SampleRedwoodRGBDImages()
im_color_path = Path(redwood.color_paths[0])
im_depth_path = Path(redwood.depth_paths[0])
camera_intrinsic_path = Path(redwood.camera_intrinsic_path)
# Load K (intrinsic).
with open(camera_intrinsic_path, "r") as f:
camera_intrinsic = json.load(f)
K = np.array(camera_intrinsic["intrinsic_matrix"]).reshape(3, 3).T
# Load T (extrinsic), assume identity.
T = np.eye(4)
# Load images and depths.
im_color = ct.io.imread(im_color_path)
im_depth = ct.io.imread_depth(im_depth_path, depth_scale=1000.0)
# Create point cloud.
points, colors = ct.project.im_depth_im_color_to_points_colors(
im_depth=im_depth, im_color=im_color, K=K, T=T
)
# Visualize.
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.colors = o3d.utility.Vector3dVector(colors)
o3d.visualization.draw_geometries([pcd])
if __name__ == "__main__":
main() |
Thanks. The explanation was really helpful. But I wanted to know the actual focal length in mm since I want to back-project my points to the depth of the image plane itself. Is there a way to know the size of the pixel in mm or the |
As far as I know, COLMAP's reconstruction of points and cameras is not physically scaled. That is, the scale is relative (or arbitrary) as we don't know the physical scale of COLMAP's reconstruction.
|
Firstly, thanks a ton for making this library. It is extremely helpful in performing common operations. I wasn't able to find anything so simple.
I have the following problem: I want to back-project the image plane to world coordinates. Basically, the depth map should contain the depth of the image plane. How can I compute this? Will they all be 1? Can you show using an example.
The text was updated successfully, but these errors were encountered: