Comments (18)
from vedo.
Got it working.. sorry was just confused by your comment about not in Jupyter earlier in the thread
from vedo.
At present, it seems that you can install by python ./setup.py install
rather pip install vtkplotter
.
Thank for your nice work!
from vedo.
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.
HI, yes the vp.camera
only 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
- or
from vtkplotter import embedWindow
embedWindow(False)
# ...
vp.show(...)
print(vp.camera) # a vtkCamera object
from vedo.
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.
@fcollman
the latest version includes the camera functions from your meshparty
project:
"cameraFromQuaternion",
"cameraFromNeuroglancer",
"orientedCamera",
"vtkCameraToK3D"
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.
I think this does address it.. except for not yet in jupyter?
from vedo.
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.
Is there any convenient way to set camera parameters like in pyrender?
from vedo.
@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.
The parameter vp.camera.SetDistance(*)
does not seem to work, how can I solve it?
ref1
ref2
from vedo.
Try with
vp.show(..., resetcam=False)
from vedo.
from vtkplotter import *
vp = Plotter()
s1 = load('dog3.off')
vp.show(s1, resetcam=False, interactive=1)
Then interact with the window, and press Shift-C,
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)
I still can't get the result of figure 2.
from vedo.
@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.
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)
Thanks @LogWell and @jby1993 for spotting the issue.
from vedo.
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
orcd vtkplotter; pip install .
will install the local copy that you may have downloaded from the git repo.
from vedo.
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)
- DistanceTool Not Working HOT 2
- plane normal HOT 3
- Adding item to Group HOT 2
- Arrow object's top point HOT 2
- Group objects HOT 1
- Help ! Legosurface Error HOT 2
- version 2024.5.2 `show()` function returns error HOT 4
- quality and resolution of the video HOT 3
- Make load functions compatible with pathlib.Path HOT 1
- Creating a plot with objects out of scene, seems to break calls to render HOT 1
- Mesh.volume() and Mesh.is_closed() don't work with Boxes and Cylinders HOT 1
- compute_normals() unexpectedly changes the appearance of a Mesh HOT 2
- Cut volume with volume HOT 1
- seg fault on vertex normal and texture indices in obj format to off conversion HOT 2
- Issues with boolean operation HOT 4
- Touching objects handling in isosurface_discrete HOT 10
- Problems with boolean operations on concave polyhedrons HOT 4
- Problem with mesh formation
- mesh.cells datatype HOT 2
- Axes order of numpy array HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.