GithubHelp home page GithubHelp logo

no Plotter.camera about vedo HOT 18 CLOSED

marcomusy avatar marcomusy commented on September 6, 2024
no Plotter.camera

from vedo.

Comments (18)

fcollman avatar fcollman commented on September 6, 2024 1

from vedo.

fcollman avatar fcollman commented on September 6, 2024 1

Got it working.. sorry was just confused by your comment about not in Jupyter earlier in the thread

from vedo.

NaGenhao avatar NaGenhao commented on September 6, 2024 1

At present, it seems that you can install by python ./setup.py install rather pip install vtkplotter.

Thank for your nice work!

from vedo.

fcollman avatar fcollman commented on September 6, 2024

i see i can set it, it just isn't there to start. Now i'm trying to figure out how to control the camera in the k3d widget.

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

HI, yes the vp.cameraonly exists after the first rendering.

The k3d backend is still a bit experimental and at present has a few limitations, loops , widget are not implemented... and camera positioning!
There are 2 ways out:
1 . use the k3d commands

from vtkplotter import settings

# ...
plt = vp.show(...)
plt

print(plt.camera) # a numpy object from k3d

see https://github.com/K3D-tools/K3D-jupyter/blob/master/examples/camera_manipulation.ipynb

  1. or
from vtkplotter import embedWindow
embedWindow(False)
# ...
vp.show(...)

print(vp.camera) # a vtkCamera object

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

Thanks a lot! Indeed you can already pass a whole camera object to vp.camera, the thing is that this is not yet translated to the k3d format.
One can either (not yet in jupyter):

vp = Plotter()

# place vtkCamera at a specific position
# (get these numbers by pressing Shift-C)
vp.camera.SetPosition([2.5, 2.5, 5.5])
vp.camera.SetFocalPoint([0.4, 0.4, 0.4])
vp.camera.SetParallelScale(1.8)
vp.camera.SetViewUp([-0.1, 1, -0.3])

or with your nice function:

vp = Plotter()

vp.camera = oriented_camera((1,1,1), up_vector=(0, -1, 0), backoff=500, backoff_vector=(0,0,1))

i'll see if I can extend it to the k3d backend.

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

@fcollman
the latest version includes the camera functions from your meshparty project:
"cameraFromQuaternion",
"cameraFromNeuroglancer",
"orientedCamera",
"vtkCameraToK3D"

https://github.com/marcomusy/vtkplotter/blob/953e2d9f9c0226bea88d93a973c85e8a210000a3/vtkplotter/utils.py#L1095

the last function is the one you were suggesting in the above messages, I hope this is addressing it, I wrote an example here:
https://github.com/marcomusy/vtkplotter/blob/master/examples/notebooks/manipulate_camera.ipynb

from vedo.

fcollman avatar fcollman commented on September 6, 2024

I think this does address it.. except for not yet in jupyter?

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

in jupyter:
https://github.com/marcomusy/vtkplotter/blob/master/examples/notebooks/manipulate_camera.ipynb

You can form your vtkCamera object
vtkcam = orientedCamera(...)

and then apply it to the rendered scene as
settings.notebook_plotter.camera = vtkCameraToK3D(vtkcam)

..or maybe you were suggesting something different?

While playing with it I realize that K3D camera has some bug (viewup is not updated if the position is not modified): K3D-tools/K3D-jupyter#180

from vedo.

LogWell avatar LogWell commented on September 6, 2024

Is there any convenient way to set camera parameters like in pyrender?

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

@LogWell
we can easily add a method in Plotter class to set camera from a numpy array..
is the k3d format adequate for it? e.i.
[posx,posy,posz, targetx,targety,targetz, upx,upy,upz]
shape in this case is (9,), or should it maybe (3,3)?

from vedo.

NaGenhao avatar NaGenhao commented on September 6, 2024

The parameter vp.camera.SetDistance(*) does not seem to work, how can I solve it?
ref1
ref2

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

Try with
vp.show(..., resetcam=False)

from vedo.

NaGenhao avatar NaGenhao commented on September 6, 2024
from vtkplotter import *

vp = Plotter()
s1 = load('dog3.off')
vp.show(s1, resetcam=False, interactive=1)

ss1

Then interact with the window, and press Shift-C, ss2

Add the output:

from vtkplotter import *

vp = Plotter()

s1 = load('dog3.off')
vp.camera.SetPosition([13.215, 3.279, 14.645])
vp.camera.SetFocalPoint([1.382, -0.444, -1.514])
vp.camera.SetViewUp([-0.066, 0.982, -0.178])
vp.camera.SetDistance(20.371)
vp.camera.SetClippingRange([16.588, 25.183])

vp.show(s1, resetcam=False, interactive=1)

ss3

I still can't get the result of figure 2.

from vedo.

jby1993 avatar jby1993 commented on September 6, 2024

@marcomusy @LogWell I also has the problem, vp.camera.SetPosition() setted value will be replaced by default value when rendered. Is this a bug?

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

This should be now fixed in the latest commit:

from vtkplotter import *

vp = Plotter()
s1 = load(datadir+'cow.vtk')

vp.camera.SetPosition( [6.316, -3.586, 1.36] )
vp.camera.SetFocalPoint( [-0.195, -0.762, -0.802] )
vp.camera.SetViewUp( [-0.245, 0.166, 0.955] )
vp.camera.SetDistance( 7.42 )
vp.camera.SetClippingRange( [4.283, 11.386] )

vp.show(s1, resetcam=0)

image

Thanks @LogWell and @jby1993 for spotting the issue.

from vedo.

marcomusy avatar marcomusy commented on September 6, 2024

thanks @NaGenhao for your feedback.

  • the command pip install vtkplotter -U installs the latest release on the pip server
  • the command python ./setup.py install or cd vtkplotter; pip install .
    will install the local copy that you may have downloaded from the git repo.

from vedo.

nantille avatar nantille commented on September 6, 2024

I'm having the same issue with this code (or any other code with camera) in a jupyter notebook.
If this is still a bug, we should reopen this issue.

!pip install vedo -U
from vedo import *

# The same issue happens without the line below and with the line below with values itk and k3d
# embedWindow('k3d')

vp = Plotter()

s1 = load(datadir+"cessna.vtk")
vp.camera.SetPosition([13.215, 3.279, 14.645])
vp.camera.SetFocalPoint([1.382, -0.444, -1.514])
vp.camera.SetViewUp([-0.066, 0.982, -0.178])
vp.camera.SetDistance(20.371)
vp.camera.SetClippingRange([16.588, 25.183])

vp.show(s1, resetcam=False, interactive=1)

Yields

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-bf81439daf12> in <module>
      7 
      8 s1 = load(datadir+"cessna.vtk")
----> 9 vp.camera.SetPosition([13.215, 3.279, 14.645])
     10 vp.camera.SetFocalPoint([1.382, -0.444, -1.514])
     11 vp.camera.SetViewUp([-0.066, 0.982, -0.178])

AttributeError: 'NoneType' object has no attribute 'SetPosition'

from vedo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.