Skip to content
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

Difference between matplotlib.pyplot and Open3D point clouds visualization in Z-axis #6674

Open
3 tasks done
hrimov opened this issue Mar 1, 2024 · 0 comments
Open
3 tasks done
Labels

Comments

@hrimov
Copy link

hrimov commented Mar 1, 2024

Checklist

My Question

I have a question why the two libraries produce the different image of the same point cloud. The difference is in the Z-axis visualization — points (in the example below lines) have different distance, but the dataset is the same.

I can understand it, because X and Y coordinates are much lower, than for Z (file attached). So, my question is how to achieve the same picture in the Open3D — maybe you already have some generic solution for it? I just figured out how to make it manually, reducing the Z-coordinate multiplying it (commented line of code in the MRE).

import matplotlib.pyplot as plt
import numpy as np
import open3d as o3d


pc_matrix = np.genfromtxt("matrix8-10.csv", delimiter=",")

# Matplotlib
x, y, z = pc_matrix[:, 0], pc_matrix[:, 1], pc_matrix[:, 2]
fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection="3d")
ax.scatter(x, y, z)
plt.show()


# Open3D
pcd = o3d.geometry.PointCloud()

# this reduces all the values of Z-axis (uncomment this line for see the desired picture)
# pc_matrix = [[point[0], point[1], point[2] * 0.3] for point in pc_matrix]

pcd.points = o3d.utility.Vector3dVector(pc_matrix)
pcd.colors = o3d.utility.Vector3dVector([[0, 0, 255] for point in pc_matrix])

visualizer = o3d.visualization.Visualizer()
visualizer.create_window()
visualizer.add_geometry(pcd)
render_option = visualizer.get_render_option()
render_option.background_color = [0, 0, 0]
visualizer.run()

So, this code produce following visualizations:
matplotlib-rectangle
open3d-rectangle

But, the desired image in Open3D is:
open3d-z-reduced-rectangle

The dataset I used for the visualization:
matrix8-10.csv

@hrimov hrimov added the question label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant