欧美free性护士vide0shd,老熟女,一区二区三区,久久久久夜夜夜精品国产,久久久久久综合网天天,欧美成人护士h版

首頁綜合 正文
目錄

柚子快報激活碼778899分享:mayavi pyqt 實例

柚子快報激活碼778899分享:mayavi pyqt 實例

http://yzkb.51969.com/

目錄

安裝:

示例代碼:

生成3d檢測框:

安裝:

pip install pyqt5 mayavi traits traitsui

示例代碼:

import sys

from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QPushButton

from traits.api import HasTraits, Instance

from traitsui.api import View, Item

from tvtk.pyface.scene_editor import SceneEditor

from mayavi.tools.mlab_scene_model import MlabSceneModel

from mayavi.core.ui.mayavi_scene import MayaviScene

class Visualization(HasTraits):

scene = Instance(MlabSceneModel, ())

def __init__(self):

HasTraits.__init__(self)

# the layout of the dialog created

view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),

height=250, width=300, show_label=False), )

class MainWindow(QMainWindow):

def __init__(self, parent=None):

super(MainWindow, self).__init__(parent)

self.setWindowTitle('Mayavi embedded in PyQt5')

# Create the main widget and layout

main_widget = QWidget()

self.setCentralWidget(main_widget)

layout = QVBoxLayout(main_widget)

# Create the Mayavi visualization

self.visualization = Visualization()

self.mayavi_scene = self.visualization.edit_traits(parent=main_widget, kind='subpanel').control

layout.addWidget(self.mayavi_scene)

# Create a button and connect its event

self.button = QPushButton('Generate 3D Mesh')

layout.addWidget(self.button)

self.button.clicked.connect(self.button_event)

def button_event(self):

# Create the data.

from numpy import pi, sin, cos, mgrid

dphi, dtheta = pi / 250.0, pi / 250.0

[phi, theta] = mgrid[0:pi + dphi * 1.5:dphi, 0:2 * pi + dtheta * 1.5:dtheta]

m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;

r = sin(m0 * phi) ** m1 + cos(m2 * phi) ** m3 + sin(m4 * theta) ** m5 + cos(m6 * theta) ** m7

x = r * sin(phi) * cos(theta)

y = r * cos(phi)

z = r * sin(phi) * sin(theta)

# View it.

self.visualization.scene.mlab.mesh(x, y, z)

if __name__ == '__main__':

app = QApplication(sys.argv)

mw = MainWindow()

mw.show()

sys.exit(app.exec_())

生成3d檢測框:

import sys

import numpy as np

from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QPushButton

from traits.api import HasTraits, Instance

from traitsui.api import View, Item

from tvtk.pyface.scene_editor import SceneEditor

from mayavi.tools.mlab_scene_model import MlabSceneModel

from mayavi.core.ui.mayavi_scene import MayaviScene

from mayavi import mlab

class Visualization(HasTraits):

scene = Instance(MlabSceneModel, ())

def __init__(self):

HasTraits.__init__(self)

# the layout of the dialog created

view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),

height=600, width=800, show_label=False), )

def draw_3d_box(self, center, size, orientation):

c, s = np.cos(orientation), np.sin(orientation)

R = np.array([

[c, -s, 0],

[s, c, 0],

[0, 0, 1]

])

l, w, h = size / 2.0

corners = np.array([

[ l, w, h],

[ l, -w, h],

[-l, -w, h],

[-l, w, h],

[ l, w, -h],

[ l, -w, -h],

[-l, -w, -h],

[-l, w, -h]

])

corners = np.dot(corners, R.T) + center

edges = [

[0, 1], [1, 2], [2, 3], [3, 0],

[4, 5], [5, 6], [6, 7], [7, 4],

[0, 4], [1, 5], [2, 6], [3, 7]

]

for edge in edges:

self.scene.mlab.plot3d(

[corners[edge[0], 0], corners[edge[1], 0]],

[corners[edge[0], 1], corners[edge[1], 1]],

[corners[edge[0], 2], corners[edge[1], 2]],

color=(1, 0, 0), tube_radius=None, line_width=1, figure=self.scene.mayavi_scene

)

class MainWindow(QMainWindow):

def __init__(self, parent=None):

super(MainWindow, self).__init__(parent)

self.setWindowTitle('Mayavi embedded in PyQt5')

# Create the main widget and layout

main_widget = QWidget()

self.setCentralWidget(main_widget)

layout = QVBoxLayout(main_widget)

# Create the Mayavi visualization

self.visualization = Visualization()

self.mayavi_scene = self.visualization.edit_traits(parent=main_widget, kind='subpanel').control

layout.addWidget(self.mayavi_scene)

# Create a button and connect its event

self.button = QPushButton('Generate 3D Detection Box')

layout.addWidget(self.button)

self.button.clicked.connect(self.button_event)

def button_event(self):

# Example data for a 3D box

center = np.array([0, 0, 0])

size = np.array([2, 1, 1])

orientation = np.pi / 4 # 45 degrees

# Draw the 3D box

self.visualization.draw_3d_box(center, size, orientation)

if __name__ == '__main__':

app = QApplication(sys.argv)

mw = MainWindow()

mw.show()

sys.exit(app.exec_())

柚子快報激活碼778899分享:mayavi pyqt 實例

http://yzkb.51969.com/

推薦鏈接

評論可見,查看隱藏內(nèi)容

本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點和立場。

轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。

本文鏈接:http://gantiao.com.cn/post/19044159.html

發(fā)布評論

您暫未設(shè)置收款碼

請在主題配置——文章設(shè)置里上傳

掃描二維碼手機(jī)訪問

文章目錄