1

I'm using Vedo in Python to visualize some 3D scans of indoor locations.

enter image description here

I would like to, e.g., add a 'camera' at (0,0,0), look left 90 degrees (or where ever), and see the camera's output.

Can this be done with Vedo? If not, is there a different python programming framework where I can open .obj files and add a camera and view through it programmatically?

martineau
  • 119,623
  • 25
  • 170
  • 301
JDS
  • 16,388
  • 47
  • 161
  • 224
  • 2
    Looks like you can supply a `camera` dict when calling the [`show()`](https://vedo.embl.es/autodocs/content/vedo/dolfin.html#vedo.dolfin.show) command. – martineau Oct 25 '21 at 18:56
  • That would be awesome. I'm quite the beginner when it comes to Vedo, any chance you could show me a bit of sample code for this? :) – JDS Oct 25 '21 at 19:16
  • 1
    Sorry, I'm not even a beginner — just looked it up in the fine documentation (after looking at a few example scripts). – martineau Oct 25 '21 at 19:50
  • 1
    What do you mean by "adding a camera"? Adding an extra independent view of the whole scene, or just modifying the view point of the one you already created? (as martineau suggested you can pass a camera dictionary for that, press C in the viewer for a template code). Feel free to open an issue on the github repo if you need more help. – mmusy Oct 26 '21 at 10:31
  • @mmusy I mean like in a video game programming environment, add a camera object to a specified position, with a specified orientation and FOV etc, and then view a (2D) image of what that camera object sees. Is it possible? – JDS Oct 26 '21 at 18:25

2 Answers2

3

I usually use schema:

...
plt = Plotter(bg='bb', interactive=False)
camera = plt.camera
plt.show(actors, axes=4, viewup='y')
for i in range(360):
   camera.Azimuth(1)  
   camera.Roll(-1)
   plt.render()
...
plt.interactive().close()

Good Luck

stansy
  • 135
  • 1
  • 10
1

You can plot the same object in an embedded renderer and control its behaviour via a simple callback function:

from vedo import *

settings.immediateRendering = False  # can be faster for multi-renderers

# (0,0) is the bottom-left corner of the window, (1,1) the top-right
# the order in the list defines the priority when overlapping
custom_shape = [
        dict(bottomleft=(0.00,0.00), topright=(1.00,1.00), bg='wheat', bg2='w' ),# ren0
        dict(bottomleft=(0.01,0.01), topright=(0.15,0.30), bg='blue3', bg2='lb'),# ren1
]

plt = Plotter(shape=custom_shape, size=(1600,800), sharecam=False)

s = ParametricShape(0) # whatever object to be shown
plt.show(s, 'Renderer0', at=0)
plt.show(s, 'Renderer1', at=1)

def update(event):
    cam = plt.renderers[1].GetActiveCamera() # vtkCamera of renderer1
    cam.Azimuth(1) # add one degree in azimuth

plt.addCallback("Interaction", update)

interactive()

enter image description here

Check out a related example here. Check out the vtkCamera object methods here.

mmusy
  • 1,292
  • 9
  • 10