Spaces:
Runtime error
Runtime error
File size: 1,468 Bytes
b727f68 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import open3d as o3d
import numpy as np
import os
from pathlib import Path
from PIL import Image
import os
from pathlib import Path
for folder_name in os.listdir("."):
if folder_name != "take_photo.py" and os.path.isdir(folder_name):
img_path = Path(folder_name) / "pc.png"
if img_path.exists():
with Image.open(img_path) as img:
new_size = (img.width // 4, img.height // 4)
img_resized = img.resize(new_size, Image.Resampling.LANCZOS)
img_resized.save( Path(folder_name) / 'pc_resized.png') # Overwrite original image
# for folder_name in os.listdir("."):
# if folder_name != "take_photo.py":
# # Load point cloud
# pcd = o3d.io.read_point_cloud(Path(folder_name) / "pc.ply")
# # Set black points
# pcd.paint_uniform_color([0, 0, 0])
# # Create a visualizer
# vis = o3d.visualization.Visualizer()
# vis.create_window(width=800, height=800) # Keep same size for all images
# vis.add_geometry(pcd)
# # Set transparent background
# opt = vis.get_render_option()
# opt.background_color = np.array([1, 1, 1]) # White background (no transparency)
# # Capture Image
# vis.poll_events()
# vis.update_renderer()
# vis.capture_screen_image(Path(folder_name) / "pc.png", do_render=True)
# vis.destroy_window()
|