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

feat(visualization): mask for unused voxels #18

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 19 additions & 6 deletions octreelib/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,37 @@ def visualize(self, config: VisualizationConfig = VisualizationConfig()) -> None
plot = k3d.Plot()
random.seed(config.seed)
poses_numbers = self.__pose_voxel_coordinates.keys()
unused_voxel_color = 0x000000 # Black

if config.type is GridVisualizationType.POSE:
for pose_number in poses_numbers:
color = random.randrange(0, 0xFFFFFF)
points = self.get_points(pose_number=pose_number)
leaves = self.get_leaf_points(pose_number=pose_number)
for leaf in leaves:
if (
true-real-michael marked this conversation as resolved.
Show resolved Hide resolved
leaf.id < len(config.voxels_mask)
and not config.voxels_mask[leaf.id]
):
color = unused_voxel_color

plot += k3d.points(
positions=points,
point_size=config.point_size,
color=color,
)
plot += k3d.points(
positions=leaf.get_points(),
point_size=config.point_size,
color=color,
)
elif config.type is GridVisualizationType.VOXEL:
voxels_colors = {}
for pose_number in poses_numbers:
leaves = self.get_leaf_points(pose_number=pose_number)
for leaf in leaves:
if leaf.id not in voxels_colors.keys():
color = random.randrange(0, 0xFFFFFF)
if (
leaf.id < len(config.voxels_mask)
true-real-michael marked this conversation as resolved.
Show resolved Hide resolved
and not config.voxels_mask[leaf.id]
):
color = unused_voxel_color

voxels_colors[leaf.id] = color

plot += k3d.points(
Expand Down
2 changes: 2 additions & 0 deletions octreelib/grid/grid_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class VisualizationConfig:
line_color: Represents color of voxels lines in Grid
visualization_filepath: Path to produced `.html` file
visualization_seed: Represents random seed for generating colors
voxels_mask: Represents mask of voxels which were used on optimisation stage
"""

type: GridVisualizationType = GridVisualizationType.VOXEL
Expand All @@ -44,6 +45,7 @@ class VisualizationConfig:
line_color: int = 0xFF0000
filepath: str = "visualization.html"
seed: int = 0
voxels_mask: List[bool] = field(default_factory=list)
true-real-michael marked this conversation as resolved.
Show resolved Hide resolved


@dataclass
Expand Down