Update app.py
Browse files
app.py
CHANGED
|
@@ -118,7 +118,7 @@ def process_image(image_path, depth_map_path=None):
|
|
| 118 |
img = Image.fromarray(blended_depth_image_8bit, mode="L")
|
| 119 |
model_3d = gr.Model3D() # Placeholder
|
| 120 |
return [img, model_3d, gltf_path]
|
| 121 |
-
|
| 122 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=10):
|
| 123 |
# Resize background to match the original image size (no cropping)
|
| 124 |
background_resized = cv2.resize(background, (foreground.shape[1], foreground.shape[0]), interpolation=cv2.INTER_LINEAR)
|
|
@@ -179,10 +179,10 @@ def create_3d_obj(foreground, depth_image, background, image_path, depth=10):
|
|
| 179 |
pcd.orient_normals_towards_camera_location(camera_location=np.array([0, 0, 0]))
|
| 180 |
|
| 181 |
# Convert the point cloud to a triangle mesh
|
| 182 |
-
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=
|
| 183 |
|
| 184 |
# Save the triangle mesh to a GLB file
|
| 185 |
-
output_path = os.path.join(
|
| 186 |
o3d.io.write_triangle_mesh(output_path, mesh)
|
| 187 |
|
| 188 |
return output_path
|
|
@@ -210,4 +210,5 @@ iface = gr.Interface(
|
|
| 210 |
allow_flagging="never",
|
| 211 |
cache_examples=False,
|
| 212 |
)
|
|
|
|
| 213 |
iface.launch(debug=True, show_api=True, share=True)
|
|
|
|
| 118 |
img = Image.fromarray(blended_depth_image_8bit, mode="L")
|
| 119 |
model_3d = gr.Model3D() # Placeholder
|
| 120 |
return [img, model_3d, gltf_path]
|
| 121 |
+
|
| 122 |
def create_3d_obj(foreground, depth_image, background, image_path, depth=10):
|
| 123 |
# Resize background to match the original image size (no cropping)
|
| 124 |
background_resized = cv2.resize(background, (foreground.shape[1], foreground.shape[0]), interpolation=cv2.INTER_LINEAR)
|
|
|
|
| 179 |
pcd.orient_normals_towards_camera_location(camera_location=np.array([0, 0, 0]))
|
| 180 |
|
| 181 |
# Convert the point cloud to a triangle mesh
|
| 182 |
+
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=depth)
|
| 183 |
|
| 184 |
# Save the triangle mesh to a GLB file
|
| 185 |
+
output_path = os.path.join("output", f"{image_path.stem}.glb")
|
| 186 |
o3d.io.write_triangle_mesh(output_path, mesh)
|
| 187 |
|
| 188 |
return output_path
|
|
|
|
| 210 |
allow_flagging="never",
|
| 211 |
cache_examples=False,
|
| 212 |
)
|
| 213 |
+
|
| 214 |
iface.launch(debug=True, show_api=True, share=True)
|