jens commited on
Commit
ba9eb63
·
1 Parent(s): 7bcdb21
Files changed (2) hide show
  1. app.py +2 -2
  2. utils.py +14 -1
app.py CHANGED
@@ -5,7 +5,7 @@ import cv2
5
  from PIL import Image
6
  import torch
7
  from inference import SegmentPredictor
8
- from utils import generate_PCL
9
 
10
 
11
 
@@ -52,7 +52,7 @@ with block:
52
  print("depth reconstruction")
53
  image = inputs[raw_image]
54
  # depth reconstruction
55
- fig = generate_PCL(image)
56
  return {pcl_figure: fig}
57
 
58
  depth_reconstruction_btn.click(on_depth_reconstruction_btn_click, components, [pcl_figure], queue=False)
 
5
  from PIL import Image
6
  import torch
7
  from inference import SegmentPredictor
8
+ from utils import generate_PCL, PCL3
9
 
10
 
11
 
 
52
  print("depth reconstruction")
53
  image = inputs[raw_image]
54
  # depth reconstruction
55
+ fig = PCL3(image)
56
  return {pcl_figure: fig}
57
 
58
  depth_reconstruction_btn.click(on_depth_reconstruction_btn_click, components, [pcl_figure], queue=False)
utils.py CHANGED
@@ -153,4 +153,17 @@ def generate_PCL(image):
153
  def plot_PCL(rgb_image, depth_image):
154
  pcd, colors = array_PCL(rgb_image, depth_image)
155
  fig = px.scatter_3d(x=pcd[:, 0], y=pcd[:, 1], z=pcd[:, 2], color=colors, size_max=0.1)
156
- return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  def plot_PCL(rgb_image, depth_image):
154
  pcd, colors = array_PCL(rgb_image, depth_image)
155
  fig = px.scatter_3d(x=pcd[:, 0], y=pcd[:, 1], z=pcd[:, 2], color=colors, size_max=0.1)
156
+ return fig
157
+
158
+
159
+ def PCL3(rgb_image, depth_image):
160
+ # Step 2: Create an RGBD image from the RGB and depth image
161
+ depth_o3d = o3d.geometry.Image(depth_image)
162
+ image_o3d = o3d.geometry.Image(rgb_image)
163
+ rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(image_o3d, depth_o3d, convert_rgb_to_intensity=False)
164
+ # Step 3: Create a PointCloud from the RGBD image
165
+ pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
166
+ # Step 4: Convert PointCloud data to a NumPy array
167
+ vis = o3d.visualization.Visualizer()
168
+ vis.add_geometry(pcd)
169
+ return vis