Closed xehartnort closed 3 months ago
Hi sorry for the late reply, I just added another method to fix this. Check out:
import vedo
import numpy as np
# Transform that moves the object out of the camera range
t = np.eye(4)
t[2, 3] = -500
inv_t = t.copy()
inv_t[2, 3] = 500
mesh = vedo.Mesh("canonical_face.obj")
cam = vedo.utils.oriented_camera(
center=(0, 0, 0), up_vector=(0, 1, 0), backoff_vector=(0, 0, 1), backoff=1.0
)
## Part: 1##########
plt = mesh.show(camera=cam, bg="black", interactive=False)
img = plt.screenshot(asarray=True)
print("Out of camera range? (It should be False): ", img.max() == 0)
vedo.Image(img).write("image0.png")
## Part: 2##########
mesh.apply_transform(t)
plt.show(mesh, interactive=False, camera=cam, bg="black")
img = plt.screenshot(asarray=True)
print("Out of camera range? (It should be True): ", img.max() == 0)
vedo.Image(img).write("image1.png")
## Part: 3########## Return to original position
mesh.apply_transform(inv_t)
plt.reset_clipping_range() ########## This line fixes the problem
plt.render()
img = plt.screenshot(asarray=True)
print("Out of camera range? (It should be False): ", img.max() == 0)
vedo.Image(img).write("image2.png")
Hi!
I think we have found a weird bug, the steps to reproduce it are shown below:
show
(thus with an empty screenshot).render(resetcam=False)
.The problem seems to disappear if the plotter instance is created with the object in camera range (
show_problem=False
)You can download the mesh in the example from: https://github.com/user-attachments/files/16443482/canonical_face.zip
Thank you for your time :smile: