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

fix: #476 improving visualization #477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MYlab10
Copy link

@MYlab10 MYlab10 commented Jul 15, 2024

earlier labelling worked for few views but this will work for all views 360 degrees

Related Issue

Closes #476

Description

use box model to be able to view all the labels in all views 360 degrees..
import pyvista as pv
from pyvista import examples
import numpy as np

Download a sample mesh (bunny model)

mesh = examples.download_bunny_coarse()

Create a Plotter object

pl = pv.Plotter()

Add the bunny mesh to the plotter

pl.add_mesh(mesh, show_edges=True, color='white')

Define the coordinate ranges for the left ear

xmin, xmax = -0.11, -0.05
ymin, ymax = 0.10, 0.18
zmin, zmax = -0.08, -0.02

Extract points within the specified ranges

points = mesh.points
mask = (
(points[:, 0] >= xmin) & (points[:, 0] <= xmax) &
(points[:, 1] >= ymin) & (points[:, 1] <= ymax) &
(points[:, 2] >= zmin) & (points[:, 2] <= zmax)
)
left_ear_points = points[mask]
#print("Extracted Points (Left Ear):")
#print(left_ear_points)

Ensure there are points in the left ear region

if left_ear_points.size > 0:
# Calculate the centroid of the extracted points
left_ear_centroid = left_ear_points.mean(axis=0)
#print("Left Ear Centroid:", left_ear_centroid)
# Add a label to the central point of the left ear
pl.add_point_labels([left_ear_centroid], ["Left Ear"], point_color='blue', point_size=10, font_size=50, text_color='black')
else:
print("No points found in the specified range for the left ear.")

Set the camera position for a better view

Adjusting the camera position to move closer to the model

pl.camera_position = [(0.1, 0.1, 0.5), # Position (closer to the model)
(0.02, 0.03, -0.02), # Focal point (focus on specific area)
(0, 1, 0)]

'''pl.camera_position = 'xy'

Ensure the plotter window is sized appropriately

pl.window_size = [800, 600]'''

Show the plot

pl.show()

Screenshots (if applicable)

Original Updated
image image

Checklist

  • [x ] My code adheres to the established style guidelines of the project.
  • [ x] I have included comments in areas that may be difficult to understand.
  • [x ] My changes have not introduced any new warnings.
  • [ x] I have conducted a self-review of my code.

earlier labelling worked for few views but this will work for all views 360 degrees
Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
virtuo-learn ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2024 5:07am

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @MYlab10! 🎉 Thank you for submitting your pull request for Virtuo-Learn. Our dedicated team will review it diligently.Your contribution is valuable and we appreciate your efforts to improve our project.

@MYlab10 MYlab10 changed the title improving 3d visualization improvement feature Jul 15, 2024
@MYlab10 MYlab10 changed the title improvement feature fix: #476 improving visualization Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] <further improvement>
1 participant