本文整理汇总了Python中pyqtgraph.opengl.GLViewWidget方法的典型用法代码示例。如果您正苦于以下问题:Python opengl.GLViewWidget方法的具体用法?Python opengl.GLViewWidget怎么用?Python opengl.GLViewWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.opengl
的用法示例。
在下文中一共展示了opengl.GLViewWidget方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def __init__(self):
"""
Initialize the graphics window and mesh surface
"""
# setup the view window
self.app = QtGui.QApplication(sys.argv)
self.window = gl.GLViewWidget()
self.window.setWindowTitle('Terrain')
self.window.setGeometry(0, 110, 1920, 1080)
self.window.setCameraPosition(distance=30, elevation=12)
self.window.show()
gx = gl.GLGridItem()
gy = gl.GLGridItem()
gz = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gy.rotate(90, 1, 0, 0)
gx.translate(-10, 0, 0)
gy.translate(0, -10, 0)
gz.translate(0, 0, -10)
self.window.addItem(gx)
self.window.addItem(gy)
self.window.addItem(gz)
model = 'mobilenet_thin_432x368'
camera = 0
w, h = model_wh(model)
self.e = TfPoseEstimator(get_graph_path(model), target_size=(w, h))
self.cam = cv2.VideoCapture("C:\\Users\\velpu\\Desktop\\tf-pose\dance.mp4")
ret_val, image = self.cam.read()
self.poseLifting = Prob3dPose('./src/lifting/models/prob_model_params.mat')
keypoints = self.mesh(image)
self.points = gl.GLScatterPlotItem(
pos=keypoints,
color=pg.glColor((0, 255, 0)),
size=15
)
self.window.addItem(self.points)
示例2: setGLViewWidget
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def setGLViewWidget(self, GLViewWidget):
self.GLViewWidget = GLViewWidget
示例3: paint
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def paint(self):
self.GLViewWidget.qglColor(self.color)
if self.pos is not None and self.text is not None:
if isinstance(self.pos, (list, tuple, np.ndarray)):
for p, text in zip(self.pos, self.text):
self.GLViewWidget.renderText(*p, text, self.font)
else:
self.GLViewWidget.renderText(*self.pos, self.text, self.font)
示例4: gl_view_widget
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def gl_view_widget():
from pyqtgraph.opengl import GLViewWidget
return GLViewWidget
示例5: create_widget
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def create_widget(self):
from pyqtgraph.opengl import GLViewWidget
if isinstance(self.parent(),AbstractQtPlotItem):
self.widget = self.parent_widget()
else:
self.widget = GLViewWidget(parent=self.parent_widget())
self.widget.opts['distance'] = 40
self.widget.raise_()
示例6: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def __init__(self, input_video):
self.traces = dict()
self.app = QtGui.QApplication(sys.argv)
self.w = gl.GLViewWidget()
self.w.opts['distance'] = 45.0 ## distance of camera from center
self.w.opts['fov'] = 60 ## horizontal field of view in degrees
self.w.opts['elevation'] = 10 ## camera's angle of elevation in degrees 仰俯角
self.w.opts['azimuth'] = 90 ## camera's azimuthal angle in degrees 方位角
self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')
self.w.setGeometry(450, 700, 980, 700) # 原点在左上角
self.w.show()
# create the background grids
gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 0)
self.w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
self.w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
self.w.addItem(gz)
# special setting
self.cap = cv2.VideoCapture(input_video)
self.video_name = input_video.split('/')[-1].split('.')[0]
self.kpt2Ds = []
pos = pos_init
for j, j_parent in enumerate(common.skeleton_parents):
if j_parent == -1:
continue
x = np.array([pos[j, 0], pos[j_parent, 0]]) * 10
y = np.array([pos[j, 1], pos[j_parent, 1]]) * 10
z = np.array([pos[j, 2], pos[j_parent, 2]]) * 10 - 10
pos_total = np.vstack([x, y, z]).transpose()
self.traces[j] = gl.GLLinePlotItem(pos=pos_total, color=pg.glColor((j, 10)), width=6, antialias=True)
self.w.addItem(self.traces[j])
示例7: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def __init__(self, skeletons_3d):
self.traces = dict()
self.app = QtGui.QApplication(sys.argv)
self.w = gl.GLViewWidget()
self.w.opts['distance'] = 45.0 ## distance of camera from center
self.w.opts['fov'] = 60 ## horizontal field of view in degrees
self.w.opts['elevation'] = 10 ## camera's angle of elevation in degrees 仰俯角
self.w.opts['azimuth'] = 90 ## camera's azimuthal angle in degrees 方位角
self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')
self.w.setGeometry(450, 700, 980, 700) # 原点在左上角
self.w.show()
# create the background grids
gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 0)
self.w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
self.w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
self.w.addItem(gz)
# special setting
pos = pos_init
self.skeleton_parents = common.skeleton_parents
self.skeletons_3d = skeletons_3d
for j, j_parent in enumerate(self.skeleton_parents):
if j_parent == -1:
continue
x = np.array([pos[j, 0], pos[j_parent, 0]]) * 10
y = np.array([pos[j, 1], pos[j_parent, 1]]) * 10
z = np.array([pos[j, 2], pos[j_parent, 2]]) * 10 - 10
pos_total = np.vstack([x, y, z]).transpose()
self.traces[j] = gl.GLLinePlotItem(pos=pos_total, color=pg.glColor((j, 10)), width=6, antialias=True)
self.w.addItem(self.traces[j])
示例8: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def __init__(self):
self.app = pg.mkQApp()
self.view = gl.GLViewWidget()
coord = gl.GLAxisItem()
glLineWidth(3)
coord.setSize(3, 3, 3)
self.view.addItem(coord)
示例9: _qtg_plot_graph
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def _qtg_plot_graph(G, edges, vertex_size, title):
qtg, gl, QtGui = _import_qtg()
if G.coords.shape[1] == 2:
window = qtg.GraphicsWindow()
window.setWindowTitle(title)
view = window.addViewBox()
view.setAspectLocked()
if edges:
pen = tuple(np.array(G.plotting['edge_color']) * 255)
else:
pen = None
adj = _get_coords(G, edge_list=True)
g = qtg.GraphItem(pos=G.coords, adj=adj, pen=pen,
size=vertex_size/10)
view.addItem(g)
global _qtg_windows
_qtg_windows.append(window)
elif G.coords.shape[1] == 3:
if not QtGui.QApplication.instance():
QtGui.QApplication([]) # We want only one application.
widget = gl.GLViewWidget()
widget.opts['distance'] = 10
widget.show()
widget.setWindowTitle(title)
if edges:
x, y, z = _get_coords(G)
pos = np.stack((x, y, z), axis=1)
g = gl.GLLinePlotItem(pos=pos, mode='lines',
color=G.plotting['edge_color'])
widget.addItem(g)
gp = gl.GLScatterPlotItem(pos=G.coords, size=vertex_size/3,
color=G.plotting['vertex_color'])
widget.addItem(gp)
global _qtg_widgets
_qtg_widgets.append(widget)
示例10: _qtg_plot_signal
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLViewWidget [as 别名]
def _qtg_plot_signal(G, signal, edges, vertex_size, limits, title):
qtg, gl, QtGui = _import_qtg()
if G.coords.shape[1] == 2:
window = qtg.GraphicsWindow(title)
view = window.addViewBox()
elif G.coords.shape[1] == 3:
if not QtGui.QApplication.instance():
QtGui.QApplication([]) # We want only one application.
widget = gl.GLViewWidget()
widget.opts['distance'] = 10
widget.show()
widget.setWindowTitle(title)
if edges:
if G.coords.shape[1] == 2:
adj = _get_coords(G, edge_list=True)
pen = tuple(np.array(G.plotting['edge_color']) * 255)
g = qtg.GraphItem(pos=G.coords, adj=adj, symbolBrush=None,
symbolPen=None, pen=pen)
view.addItem(g)
elif G.coords.shape[1] == 3:
x, y, z = _get_coords(G)
pos = np.stack((x, y, z), axis=1)
g = gl.GLLinePlotItem(pos=pos, mode='lines',
color=G.plotting['edge_color'])
widget.addItem(g)
pos = [1, 8, 24, 40, 56, 64]
color = np.array([[0, 0, 143, 255], [0, 0, 255, 255], [0, 255, 255, 255],
[255, 255, 0, 255], [255, 0, 0, 255], [128, 0, 0, 255]])
cmap = qtg.ColorMap(pos, color)
signal = 1 + 63 * (signal - limits[0]) / limits[1] - limits[0]
if G.coords.shape[1] == 2:
gp = qtg.ScatterPlotItem(G.coords[:, 0],
G.coords[:, 1],
size=vertex_size/10,
brush=cmap.map(signal, 'qcolor'))
view.addItem(gp)
if G.coords.shape[1] == 3:
gp = gl.GLScatterPlotItem(pos=G.coords,
size=vertex_size/3,
color=cmap.map(signal, 'float'))
widget.addItem(gp)
if G.coords.shape[1] == 2:
global _qtg_windows
_qtg_windows.append(window)
elif G.coords.shape[1] == 3:
global _qtg_widgets
_qtg_widgets.append(widget)