jens commited on
Commit
1faf11a
·
1 Parent(s): 9a4514d
Files changed (1) hide show
  1. utils.py +14 -1
utils.py CHANGED
@@ -5,6 +5,7 @@ import plotly.express as px
5
  import numpy as np
6
  import pandas as pd
7
  from inference import DepthPredictor
 
8
 
9
  def create_3d_obj(rgb_image, depth_image, depth=10, path='./image.gltf'):
10
  depth_o3d = o3d.geometry.Image(depth_image)
@@ -169,4 +170,16 @@ def PCL3(image):
169
  # Step 4: Convert PointCloud data to a NumPy array
170
  vis = o3d.visualization.Visualizer()
171
  vis.add_geometry(pcd)
172
- return vis
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  import numpy as np
6
  import pandas as pd
7
  from inference import DepthPredictor
8
+ import matplotlib.pyplot as plt
9
 
10
  def create_3d_obj(rgb_image, depth_image, depth=10, path='./image.gltf'):
11
  depth_o3d = o3d.geometry.Image(depth_image)
 
170
  # Step 4: Convert PointCloud data to a NumPy array
171
  vis = o3d.visualization.Visualizer()
172
  vis.add_geometry(pcd)
173
+ # Step 4: Convert PointCloud data to a NumPy array
174
+ points = np.asarray(pcd.points)
175
+ colors = np.asarray(pcd.colors)
176
+ # Step 5: Create a DataFrame from the NumPy arrays
177
+ #data = {'x': points[:, 0], 'y': points[:, 1], 'z': points[:, 2],
178
+ # 'red': colors[:, 0], 'green': colors[:, 1], 'blue': colors[:, 2]}
179
+ #df = pd.DataFrame(data)
180
+ # Step 6: Create a 3D scatter plot using Plotly Express
181
+ #fig = px.scatter_3d(df, x='x', y='y', z='z', color='red', size_max=0.1)
182
+ fig = plt.figure()
183
+ ax = fig.add_subplot(projection='3d')
184
+ ax.scatter(points[:, 0], points[:, 1], points[:, 2], marker='o', s=0.01, c=colors)
185
+ return fig