codic commited on
Commit
745805f
·
verified ·
1 Parent(s): 15d00d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -84,12 +84,20 @@ def create_3d_obj(rgb_image, depth_image, image_path, depth=12):
84
  camera_intrinsic = o3d.camera.PinholeCameraIntrinsic()
85
  camera_intrinsic.set_intrinsics(w, h, 1000, 1000, w / 2, h / 2)
86
 
87
- # Create Point Cloud
88
  pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, camera_intrinsic)
89
 
90
- # Estimate normals and orient them towards the camera location
91
- pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.05, max_nn=30))
92
- pcd.orient_normals_towards_camera_location(camera_location=np.array([0.0, 0.0, 1000.0]))
 
 
 
 
 
 
 
 
93
 
94
  # Transformations
95
  pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
 
84
  camera_intrinsic = o3d.camera.PinholeCameraIntrinsic()
85
  camera_intrinsic.set_intrinsics(w, h, 1000, 1000, w / 2, h / 2)
86
 
87
+ # Create Point Cloud from RGBD Image
88
  pcd = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd_image, camera_intrinsic)
89
 
90
+ # Ensure normals are estimated before trying to orient them
91
+ if not pcd.has_normals():
92
+ print("Estimating normals for point cloud...")
93
+ pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.05, max_nn=30))
94
+
95
+ # Confirm if normals are present
96
+ if pcd.has_normals():
97
+ print("Orienting normals towards camera location...")
98
+ pcd.orient_normals_towards_camera_location(camera_location=np.array([0.0, 0.0, 1000.0]))
99
+ else:
100
+ raise RuntimeError("Failed to estimate normals for the point cloud.")
101
 
102
  # Transformations
103
  pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])