Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

出力先arg追加 #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ply_processor_basics/stl/stl2ply.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
#!/usr/bin/env /usr/bin/python3

import os
from typing import List

import numpy as np
import open3d as o3d


def stl2ply(
name: str, cam_dir: List[float] = [-100.0, -100, 100], sample_points: int = 1000000, voxel_size: float = 1.0
name: str,
cam_dir: List[float] = [-100.0, -100, 100],
sample_points: int = 1000000,
voxel_size: float = 1.0,
outdir="out",
):
"""
Convert a .stl file to a .ply file, output at `out` directory
:param name: name of the .stl file
:param cam_dir: camera direction
:param sample_points: number of points to sample
:param voxel_size: size of the voxel
:return: None
"""
mesh = o3d.io.read_triangle_mesh(name + ".stl")
mesh.compute_vertex_normals()
pcd = mesh.sample_points_uniformly(number_of_points=sample_points)
Expand All @@ -22,4 +35,5 @@ def stl2ply(

pcd = pcdd.select_by_index(pt_map)

o3d.io.write_point_cloud(name + ".ply", pcd)
os.makedirs(outdir, exist_ok=True)
o3d.io.write_point_cloud(f"{outdir}/{name}.ply", pcd)
Loading