generated from HiraiKyo/pyproject-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,596 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
matrix/ | ||
points/ | ||
pcd/ | ||
|
||
.mypy_cache/ | ||
.env | ||
.env.local | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-python.mypy-type-checker", | ||
"matangover.mypy", | ||
"usernamehw.errorlens", | ||
"littlefoxteam.vscode-python-test-adapter", | ||
"oderwat.indent-rainbow", | ||
"shardulm94.trailing-spaces", | ||
"hediet.vscode-drawio" | ||
"charliermarsh.ruff", | ||
"ms-python.mypy-type-checker", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
# pyproject-boilerplate | ||
# ply-processor-basics | ||
|
||
Boilerplate for Python Project | ||
Basic libraries for manipulating point cloud. | ||
|
||
## Purpose | ||
## Methods | ||
|
||
- Type-safe | ||
- Good lint rules. | ||
- Well-developed with VSCode | ||
### Vector | ||
|
||
## Stacks | ||
#### `vector.normalize` | ||
|
||
- Poetry | ||
- Ruff | ||
- Mypy, Pydantic | ||
- Pytest | ||
### Points | ||
|
||
## Structure | ||
#### `points.rotate_euler` | ||
|
||
## Installation | ||
#### `points.get_distances_line` | ||
|
||
```sh | ||
poetry install | ||
``` | ||
|
||
## References | ||
|
||
- [https://qiita.com/tamo_breaker/items/dbd8482e88c61269d531] | ||
#### `points.get_distances_plane` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
!.gitignore | ||
!sample/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env /usr/bin/python3 | ||
|
||
import numpy as np | ||
import open3d as o3d | ||
|
||
names = [ | ||
"outer_mast_AX-VT-Fusion", | ||
"outer_mast_AX-VT_inverse-Fusion", | ||
"middle_mast_outside_AX-VT-Fusion", | ||
] | ||
|
||
|
||
def gen_ply(name: str): | ||
mesh = o3d.io.read_triangle_mesh(name + ".stl") | ||
mesh.compute_vertex_normals() | ||
pcd = mesh.sample_points_uniformly(number_of_points=1000000) | ||
pcdd = pcd.voxel_down_sample(voxel_size=1.0) | ||
o3d.visualization.draw_geometries([pcdd]) | ||
|
||
diameter = np.linalg.norm( | ||
np.asarray(pcdd.get_max_bound()) - np.asarray(pcdd.get_min_bound()) | ||
) | ||
camera = np.array([-100, -100, 100]) | ||
radius = diameter * 100 | ||
|
||
_, pt_map = pcdd.hidden_point_removal(camera, radius) | ||
|
||
pcd = pcdd.select_by_index(pt_map) | ||
|
||
o3d.io.write_point_cloud(name + ".ply", pcd) | ||
o3d.visualization.draw_geometries([pcd]) | ||
|
||
|
||
if __name__ == "__main__": | ||
for name in names: | ||
gen_ply(name) |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .normalize import normalize as normalize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
from numpy.typing import NDArray | ||
|
||
|
||
def normalize(vector: NDArray[np.float32]) -> NDArray[np.float32]: | ||
"""_summary_ | ||
Args: | ||
vector (NDArray[np.float32]): _description_ | ||
Returns: | ||
NDArray[np.float32]: _description_ | ||
""" | ||
if np.linalg.norm(vector) == 0: | ||
raise ZeroDivisionError("The norm of the vector is zero.") | ||
|
||
return vector / np.linalg.norm(vector) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,25 @@ test = {cmd = "dotenv --file envs/.env.development run -- pytest", help = "Run u | |
dev-python = {cmd = "dotenv --file envs/.env.development run -- python", help = "Run python with dev environment."} | ||
|
||
[tool.poetry] | ||
name = "example_pyproject" | ||
name = "ply_processor_basics" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["HiraiKyo <[email protected]>"] | ||
license = "MIT" | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.11" | ||
python = "3.8.19" | ||
python-dotenv = "^1.0.1" | ||
pydantic = "^2.7.4" | ||
open3d = "^0.18.0" | ||
scikit-learn = "1.3.2" | ||
pyyaml = "^6.0.2" | ||
addict = "^2.4.0" | ||
pillow = "^10.4.0" | ||
pandas = "2.0.3" | ||
tqdm = "^4.66.5" | ||
numpy = "1.24.4" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
ruff = "^0.5.0" | ||
|
@@ -23,20 +31,24 @@ pytest-env = "^1.1.3" | |
taskipy = "^1.13.0" | ||
|
||
[tool.ruff] | ||
target-version = "py311" | ||
target-version = "py38" | ||
line-length = 120 | ||
|
||
[tool.mypy] | ||
python_version = "3.8" | ||
warn_return_any = true | ||
warn_unused_configs = true | ||
disallow_untyped_defs = true | ||
strict = true | ||
disallow_untyped_defs = false | ||
|
||
[tool.pytest.ini_options] | ||
testpaths = [ | ||
"tests", | ||
] | ||
|
||
[[tool.mypy.overrides]] | ||
module = ["open3d", "pandas", "sklearn", "sklearn.cluster", "scipy.spatial.transform"] | ||
ignore_missing_imports = true | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
requires = ["setuptools","poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import numpy as np | ||
from pytest import approx | ||
|
||
from ply_processor_basics.vector import normalize | ||
|
||
|
||
def test_normalize_success() -> None: | ||
v = np.array([1, 1, 0]) | ||
normed = normalize(v) | ||
assert normed == approx([1 / np.sqrt(2), 1 / np.sqrt(2), 0]) | ||
|
||
v = np.array([1, 1, 1]) | ||
normed = normalize(v) | ||
assert normed == approx([1 / np.sqrt(3), 1 / np.sqrt(3), 1 / np.sqrt(3)]) | ||
|
||
|
||
def test_normalize_failed() -> None: | ||
v = np.array([0, 0, 0]) | ||
# expecting raise ZeroDivisionError | ||
try: | ||
normalize(v) | ||
assert False | ||
except ZeroDivisionError: | ||
assert True |