installing Mayavi with pip - no module named 'vtkOpenGLKitPython'
I am trying to install mayavi via pip on my ubuntu 16.04 via shell. I am using python 3.6 via anaconda and already installed vtk and all other requirements but i get the above error when i try pip3 install mayavi or pip2 install mayavi.
See also questions close to this topic
VTK cutter output
I am seeking a solution of connecting all the lines that have the same slope and share a common point. For example, after I load a STL file and cut it using a plane, the cutter output includes the points defining the contour. Connecting them one by one forms a (or multiple) polyline. However, some lines can be merged when their slopes are the same and they share a common point. E.g., [[0,0,0],[0,0,1]] and [[0,0,1],[0,0,2]] can be represented by one single line [[0,0,0],[0,0,2]].
I wrote a function that can analyse all the lines and connect them if they can be merged. But when the number of lines are huge, this process is slow. I am thinking in the VTK pipeline, is there a way to do the line merging?
plane = vtk.vtkPlane() plane.SetOrigin([0,0,5]) plane.SetNormal([0,0,1]) cutter = vtk.vtkCutter() cutter.SetCutFunction(plane) cutter.SetInput(triangleFilter.GetOutput()) cutter.Update() cutStrips = vtk.vtkStripper() cutStrips.SetInputConnection(cutter.GetOutputPort()) cutStrips.Update() cleanDataFilter = vtk.vtkCleanPolyData() cleanDataFilter.AddInput(cutStrips.GetOutput()) cleanDataFilter.Update() cleanData = cleanDataFilter.GetOutput() print cleanData.GetPoint(0) print cleanData.GetPoint(1) print cleanData.GetPoint(2) print cleanData.GetPoint(3) print cleanData.GetPoint(4)
The output is:
(0.0, 0.0, 5.0) (5.0, 0.0, 5.0) (10.0, 0.0, 5.0) (10.0, 5.0, 5.0) (10.0, 10.0, 5.0)
Connect the above points one by one will form a polyline representing the cut result. As we can see, the line [point0, point1] and [point1, point2] can be merged.
Below is the code for merging the lines: Assume that the LINES are represented by list: [[(p0),(p1)],[(p1),(p2)],[(p2),(p3)],...]
appended = 0 CurrentLine = LINES CurrentConnectedLine = CurrentLine tempLineCollection = LINES[1:len(LINES)] while True: for HL in tempLineCollection: QCoreApplication.processEvents() if checkParallelAndConnect(CurrentConnectedLine, HL): appended = 1 LINES.remove(HL) CurrentConnectedLine = ConnectLines(CurrentConnectedLine, HL) processedPool.append(CurrentConnectedLine) if len(tempLineCollection) == 1: processedPool.append(tempLineCollection) LINES.remove(CurrentLine) if len(LINES) >= 2: CurrentLine = LINES CurrentConnectedLine = CurrentLine tempLineCollection = LINES[1:len(LINES)] appended = 0 else: break
VTK compiled and installed using cmake QVTKWidget.h cannot be found (Ubuntu)
I am on Ubuntu 17.10 and downloaded/compiled and installed the latest VTK-libraries using cmake (for the first time). using following commands
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. make -j7 sudo make install
Now, in my Project cmake can find VTK, but during compilation it says
QVTKWidget.h cannot be found. I can find the file in
/home/libraries/VTK-8.1.0/GUISupportbut it is not in the
/usr/local/include/where the rest has been installed to.
How do I get the compiler to find the headers? It is probably not clean to just copy them into the
.../include/folder, is it?
VTK: Alternative to matlabs imfill
is there any alternative method in VTK, similliar to matlabs image-processing toolboxes method Imfill?
Mayavi scripting raycast function
I am having difficulty setting a ray_cast_function from a python script for Mayavi volume rendering. My usual approach is to record the "mayavi scrip" from the pipeline gui and then emulate that code in my .py script. Naively I thought the below would work:
#create some volume volume = mlab.pipeline.volume(src) volume.ray_cast_function_type = 'RayCastCompositeFunction' volume.volume_mapper_type = 'RayCastMapper' volume.ray_cast_function_type = 'RayCastMIPFunction'
However, I get the following error:
/mayavi-4.5.1.dev0-py2.7-linux-x86_64.egg/mayavi/core/trait_defs.py", line 97, in set_value raise TraitError(object, name,"one of %s"%values, value) traits.trait_errors.TraitError: The 'ray_cast_function_type' trait of a Volume instance must be one of [''], but a value of 'RayCastCompositeFunction' <type 'str'> was specified.
I am sure there must be a way to script this, but the source code doesn't seem to reveal an obvious way.
mayavi and vtk don't not work when updating tensorflow from v1.2 to v1.4 and updating cudnn from v5.1 to v6.0
When I update tensorflow1.2 to tensorflow1.4 and cudnn5.1 to 6.0,I find that the 3d data visual tool,Mayavi, can't work anymore.The detials are as below.
when I write code like this:
import mayavi.mlab as mlab import tensorflow as tf fig = mlab.figure(figure=None, bgcolor=(0, 0, 0), fgcolor=None, engine=None, size=(1000, 500)) mlab.points3d(pxs, pys, pzs, prs,mode='point',colormap='gnuplot', figure=fig) mlab.view(azimuth=180, elevation=None, distance=50,focalpoint=[12.0909996, -1.04700089, -2.03249991]) mlab.show()
it works well when the system installed tensorflow 1.2 but when I write the same code as before after updating tf,it has the bug info:
ERROR: In /build/buildd/vtk-5.8.0/Rendering/vtkXOpenGLRenderWindow.cxx, line 631 vtkXOpenGLRenderWindow (0x558dd20): Cannot create GLX context. Aborting.
It seems to be relative about vtk and opengl. BUT when I delete the code "import tensorflow as tf" like below,
import mayavi.mlab as mlab fig = mlab.figure(figure=None, bgcolor=(0, 0, 0), fgcolor=None, engine=None, size=(1000, 500)) mlab.points3d(pxs, pys, pzs, prs,mode='point',colormap='gnuplot', figure=fig) mlab.view(azimuth=180, elevation=None, distance=50,focalpoint=[12.0909996, -1.04700089, -2.03249991]) mlab.show()
the mayavi can work well as before! I have solving this problem for two days and still cant find a solution.
- ubuntu 14.04
- tensorflow 1.4 cudnn 6.0
- configuration: driver=nvidia latency=0
- OpenGL vendor string: NVIDIA Corporation OpenGL renderer string: GeForce GTX 950/PCIe/SSE2 OpenGL core profile version string: 4.3.0 NVIDIA 375.66 OpenGL core profile shading language version string: 4.30 NVIDIA via Cg compiler OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 4.5.0 NVIDIA 375.66 OpenGL shading language version string: 4.50 NVIDIA OpenGL context flags: (none) OpenGL profile mask: (none)
Mayavi.mlab: scale/limit/set axes or aspect ratio
I have data that essentially looks like that: (minimum working example)
import mayavi.mlab as mlab pts = mlab.points3d([1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,500], [1,2,3,4,100]) mlab.show()
And this already shows my problem: because of the huge outlier in
z, the other points are barely visible. In the visualized result, the
zaxis is multiple times larger than the
yaxis. Now, let's disregard that I have the same problem for size (matplotlib let's you neatly define size as
s^2in points, where I didn't have this problem), is there a way to get a plot with a neat aspect ratio that isn't essentially just a line?
I know about the
extentparameter to enforce a square plot (
[0,1,0,1,0,1]) but this squashes/distorts all drawn elements and turns my spheres into flat puddles of dye. I cannot use
mode = 'point'to prevent the distortion of
extentbecause the size of each data point is relevant.
I'm coming from matplotlib because multiple occlusion problems with
mplot3dmade it impossible to use the plot result. However, in matplotlib not only is a neatly autoscaled aspect ratio default, it is trivial to change the aspect ratio without distorting the drawn elements. It is also simple to limit axis ranges by hand is necessary.
Is there any way to do any of this in
mayavi.mlab? I really don't want to "simulate" this by scaling the data because this will lead to new trouble with axis labels etc.