コード例 #1
0
 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)
コード例 #2
0
    def __init__(self,
                 data_shape=1024,
                 color=(1.0, 0.0, 0.0, 1.0),
                 start_angle=-3 * np.pi / 4.,
                 stop_angle=3 * np.pi / 4.,
                 widget=None):
        if not widget:
            self.app = QtGui.QApplication([])
            self.widget = gl.GLViewWidget()
            self.widget.opts['distance'] = 40
            self.widget.show()
        else:
            self.widget = widget

        self.axis = gl.GLAxisItem()
        self.axis.translate(0, 0, 1)
        self.widget.addItem(self.axis)

        self.gz = gl.GLGridItem()
        self.widget.addItem(self.gz)

        radius = np.ones((data_shape)) * 5
        self.start_angle = start_angle
        self.stop_angle = stop_angle
        self.angle = np.linspace(self.start_angle, self.stop_angle, data_shape)
        x = np.sin(self.angle) * radius
        y = np.cos(self.angle) * radius
        z = np.ones((data_shape))
        pts = np.vstack([x, y, z]).transpose()
        # self.line_plot = gl.GLLinePlotItem(pos=pts, color=np.array(color * data_shape).reshape((data_shape, 3)))
        self.line_plot = gl.GLScatterPlotItem(
            pos=pts,
            color=np.array(color * data_shape).reshape((data_shape, 4)),
            size=3.0)
        self.widget.addItem(self.line_plot)
コード例 #3
0
    def __init__(self, defaultNumberOfData, parent=None, **kargs):
        super().__init__()
        self.numberOfData = defaultNumberOfData
        self.widthOfData = 500
        self.offset = 0
        # pg.GraphicsWindow.__init__(self, **kargs)
        gl.GLViewWidget.__init__(self, **kargs)
        self.setParent(parent)
        self.setWindowTitle('Radar-Plot')

        self.addSurfaceGraph()

        self.show()
        self.setWindowTitle('PAS Surfaceplot')
        self.setGeometry(100, 100, 1500, 800)  # distance && resolution
        self.setCameraPosition(distance=1000)

        ## Create axis
        # axis = pg.AxisItem('left', pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)
        # axis.show()
        # axis = pg.AxisItem('left', pen = None)
        # xAxis.paint()
        # Axis.setSize(self.valueNumber, self.valueNumber, self.valueNumber)
        # axis.setStyle(showValues = True)
        # axis.show()
        # --------------------
        axis = gl.GLAxisItem()
        axis.setSize(x=1000, y=1000, z=1000, size=None)
        # xAxis.paint()
        # axis.setSize(self.valueNumber, self.valueNumber, self.valueNumber)
        self.addItem(axis)
コード例 #4
0
    def __init__(self, title='null'):
        """
        :param title:
        """
        self.glview = gl.GLViewWidget()
        coord = gl.GLAxisItem()
        coord.setSize(1, 1, 1)
        # self.glview.addItem(coord)
        self.glview.setMinimumSize(QtCore.QSize(600, 500))
        self.glview.pan(1, 0, 0)
        self.glview.setCameraPosition(azimuth=180)
        self.glview.setCameraPosition(elevation=0)
        self.glview.setCameraPosition(distance=5)
        self.items = []

        self.view = QtGui.QWidget()
        self.view.window().setWindowTitle(title)
        hlayout = QtGui.QHBoxLayout()
        snap_btn = QtGui.QPushButton('&Snap')

        def take_snap():
            qimg = self.glview.readQImage()
            qimg.save('1.jpg')

        snap_btn.clicked.connect(take_snap)
        hlayout.addWidget(snap_btn)
        hlayout.addStretch()
        layout = QtGui.QVBoxLayout()

        layout.addLayout(hlayout)
        layout.addWidget(self.glview)
        self.view.setLayout(layout)
コード例 #5
0
 def __init__(self, parent=None):
     super().__init__(parent)
     
     self.computation=Computation()
     
     self.axes=gl.GLAxisItem(size=None, antialias=True, glOptions='translucent')
     self.addItem(self.axes)
     
     self.BrittleStar=BrittleStar()
     self.brittlestar_tail=BrittleStar_Tail()
     
     self.addItem(self.BrittleStar)
     self.addItem(self.brittlestar_tail)
     
     self.xygrid = gl.GLGridItem()
     self.xygrid.setSize(5,5,0)
     self.xygrid.setSpacing(1,1,0)
     self.xygrid.translate(0, 0, 0)
     self.addItem(self.xygrid)
     
     self.timer=QtCore.QTimer()
     self.timer.setInterval(100) #in ms
     self.timer.timeout.connect(self.refresh_anim)
     
     self.initial_pos=np.array([0,0,0])
     self.prev_pos=self.initial_pos
     self.initial_angle=np.array([0,0,0])
     self.prev_angle=self.initial_angle
コード例 #6
0
def surface3d(xs, ys, zs, colors, start=0, end=-1, step=1):
    w = gl.GLViewWidget()
    nx, ny, nz = [], [], []
    for i, x in enumerate(xs):
        sampled_x = x[start:end:step]
        sampled_y = ys[i][start:end:step] - ys[i][0]
        z = np.ones(len(sampled_x)) * zs[i]
        nx.append(sampled_x)
        ny.append(sampled_y)
        nz.append(z)

    verts = [np.array([nx[0], ny[0], nz[0]]).transpose()]
    faces = []
    for i in range(1, len(nx)):
        nverts = np.array([nx[i], ny[i], nz[i]]).transpose()
        nfaces = []
        #TODO

        plt = plot_line(sampled_x, sampled_y, z, color=colors[i])
        w.addItem(plt)
    #add_grids(w)
    ax = gl.GLAxisItem()

    w.addItem(ax)
    ##w.pan(0,0,0)
    return w
コード例 #7
0
 def set_new_axis(self, parent_object):
     """Adds axis to given object"""
     axis = gl.GLAxisItem(antialias=True, glOptions='opaque')
     axis.updateGLOptions({'glLineWidth': (3, )})
     axis.setParentItem(parent_object)
     self.view3D.addItem(axis)
     return axis
コード例 #8
0
    def __init__(self, x=0, y=0, z=0, scale=0.1, widget=None):
        """
        If there is no widget given a new window is created and its id is accessible via self.widget.
        :param x: optional, float
        :param y: optional, float
        :param z: optional, float
        :param widget: optional, gl.GLViewWidget
        :return: None
        """
        if not widget:
            self.app = QtGui.QApplication([])
            self.widget = gl.GLViewWidget()
            self.widget.opts['distance'] = 40
            self.widget.show()
        else:
            self.app = False
            self.widget = widget

        self.scale = scale
        self.x = x
        self.y = y
        self.z = z
        self.rot0 = 0
        self.rot1 = 0
        self.rot2 = 0

        self.axis = gl.GLAxisItem()
        tr = pg.Transform3D()
        tr.scale(self.scale)
        tr.rotate(self.rot0, 1, 0, 0)
        tr.rotate(self.rot1, 0, 1, 0)
        tr.rotate(self.rot2, 0, 0, 1)
        self.axis.setTransform(tr)
        self.axis.translate(self.x, self.y, self.z)
        self.widget.addItem(self.axis)
コード例 #9
0
ファイル: plotCamera.py プロジェクト: wqhot/ZNTKGUI
    def __init__(self, layout):
        self.w = gl.GLViewWidget()
        self.w.opts['distance'] = 1.0
        # self.w.show()
        # self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')

        gx = gl.GLGridItem()
        gx.rotate(90, 0, 0.1, 0)
        gx.translate(-10, 0, 0)
        self.w.addItem(gx)
        gy = gl.GLGridItem()
        gy.rotate(90, 0.1, 0, 0)
        gy.translate(0, -10, 0)
        self.w.addItem(gy)
        gz = gl.GLGridItem()
        gz.translate(0, 0, -10)
        self.w.addItem(gz)

        axis = gl.GLAxisItem()
        axis.setSize(0.2, 0.2, 0.2)
        self.w.addItem(axis)

        self.x_text = gl.GLTextItem(pos=(0.2,0,0), text="x", font=QtGui.QFont('Helvetica', 7))
        self.w.addItem(self.x_text)
        self.y_text = gl.GLTextItem(pos=(0,0.2,0), text="y", font=QtGui.QFont('Helvetica', 7))
        self.w.addItem(self.y_text)
        self.z_text = gl.GLTextItem(pos=(0,0,0.2), text="z", font=QtGui.QFont('Helvetica', 7))
        self.w.addItem(self.z_text)
        self.hfov = 90.0
        self.vfov = 60.0
        self.cam_rotmat = Rotation.from_rotvec([0., 0., 0.])
        self.cam_t = np.array([0., 0., 0.])
        self.max_depth = 0.01 # 相机深度

        self.imlt = [-0.01, -0.005, 0.01]
        self.imrt = [0.01, -0.005, 0.01]
        self.imlb = [-0.01, 0.005, 0.01]
        self.imrb = [0.01, 0.005, 0.01]
        self.oc = [0.0, 0.0, 0.0]
        self.cal_cam_fov()
        self.lines = []
        pos = np.empty((TIME_LENGTH, 3))
        size = np.empty((TIME_LENGTH))
        color = np.empty((TIME_LENGTH, 4))
        self.fix_points = None
        self.points = None
        self.currentSTL = None
        self.showSTL('./res/helmat.stl')
        self.head_last_rot = Rotation.from_quat([0,0,0,1])
        self.head_last_trans = np.array([0., 0., 0.])
        for i in range(TIME_LENGTH):
            pos[i] = (0, 0, 0)
            size[i] = 0.005
            color[i] = (i * 1.0 / TIME_LENGTH, 0.0, 0.0, 1.0)
        self.history = gl.GLScatterPlotItem(pos=pos, size=size, color=color, pxMode=False)
        self.w.addItem(self.history)
        for i in range(8):
            self.lines.append(gl.GLLinePlotItem(antialias=True))
            self.w.addItem(self.lines[i])
        layout.addWidget(self.w)
コード例 #10
0
    def __init__(self, mesh_path, *args, **kwargs):
        super(PlaneWidget, self).__init__(*args, **kwargs)
        self.setCameraPosition(distance=40)

        g = gl.GLGridItem()
        g.scale(2, 2, 1)
        g.translate(0, 0, -2)
        self.addItem(g)

        self.plane_axis = gl.GLAxisItem()
        self.plane_axis.setSize(x=1000, y=500, z=500)
        self.addItem(self.plane_axis)

        verts = self._get_mesh_points(mesh_path)
        faces = np.array([(
            i,
            i + 1,
            i + 2,
        ) for i in range(0, len(verts), 3)])
        colors = np.array([(
            0.0,
            1.0,
            0.0,
            1.0,
        ) for i in range(0, len(verts), 3)])
        self.mesh = gl.GLMeshItem(vertexes=verts,
                                  faces=faces,
                                  faceColors=colors,
                                  smooth=False,
                                  shader='shaded')
        self.addItem(self.mesh)
        self._update_mesh(Record(None))
コード例 #11
0
    def __init__(self, *args, data=None, **kwargs):
        """
        Set up the :class: `GLViewWidget <pyqtgraph.opengl.GLViewWidget>` 
        as this widget's central widget.
        """
        super().__init__(*args, **kwargs)

        # Initialize instance variables
        self.data = TracedVariable(None, name='data')
        self.cmap = load_cmap(DEFAULT_CMAP)
        self.lut = self.cmap.getLookupTable()
        self.gloptions = 'translucent'

        # Create a GLViewWidget and put it into the layout of this view
        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)
        self.glview = gl.GLViewWidget()

        # Add the scalebar
        self._initialize_sub_widgets()

        # Put all widgets in place
        self.align()

        # Add some coordinate axes to the view
        self.coordinate_axes = gl.GLAxisItem()
        self.glview.addItem(self.coordinate_axes)
        self.set_coordinate_axes(True)

        # Try to set the default data
        if data is not None:
            self.set_data(data)
コード例 #12
0
    def do_render(self, projected):
        projected = self.rescale(projected)

        x, y, z, _ = projected.shape
        print(x, y, z)
        d = float(max(x, y, z) * 2)

        if self.plot is None:
            self.plot = gl.GLVolumeItem(projected, smooth=False)
            self.addItem(self.plot)
            self.axis = gl.GLAxisItem(glOptions="opaque")
            self.addItem(self.axis)
            self.opts['distance'] = self.distance = d
        else:
            # Latest version has .setData but is not in PyPi
            self.plot.data = projected
            self.plot.initializeGL()

        ratio = d / self.distance

        self.opts['distance'] *= ratio
        self.distance = d

        self.plot.resetTransform()
        self.plot.translate(-x / 2, -y / 2, -z / 2)

        self.axis.setSize(x, y, z)
        self.axis.resetTransform()
        self.axis.translate(-x / 2, -y / 2, -z / 2)
コード例 #13
0
    def __init__(self,
                 pos=None,
                 color=(100, 100, 200),
                 data_shape=1000,
                 widget=None):
        if not widget:
            self.app = QtGui.QApplication([])
            self.widget = gl.GLViewWidget()
            self.widget.opts['distance'] = 40
            self.widget.show()
        else:
            self.widget = widget

        self.axis = gl.GLAxisItem()
        self.widget.addItem(self.axis)

        self.box_item_list = []

        if pos is None:
            x = (np.random.rand((data_shape)) - 0.5) * 20
            y = (np.random.rand((data_shape)) - 0.5) * 20
            z = (np.random.rand((data_shape)) - 0.5) * 20
            pos = np.vstack([x, y, z]).transpose()
        self.add_new_box(pos)

        surface_plot = gl.GLSurfacePlotItem()
        colors = np.array((((0.5, 0.5, 0.5, 0.25), (0.5, 0.5, 1, 0.25)),
                           ((1, 0.5, 0.5, 0.25), (0.5, 1, 0.5, 0.25))))
        surface_plot.setData(x=np.array((-10, 10)),
                             y=np.array((-10, 10)),
                             z=np.array(((0, 0), (0, 0))),
                             colors=colors)
        self.widget.addItem(surface_plot)
コード例 #14
0
    def processFace(self, edgePair):
        """
        Using ransac, calculates the normals for the currently selected edge pairs and displays a vectors
        corresponding the orientatoin of the face.
        """
        self.currentEdgePair = edgePair
        # if self.grabberElement is not None:
        #     self.removeItem(self.grabberElement)
        self.grabberElement = GrabberElement(self.context)
        self.addItem(self.grabberElement, group=RenderGroup.Variable)

        self.grabberElement.show()
        length = 10

        position = edgePair.getCenterPoint3D()
        eigenVectors = edgePair.getOrientation()
        # make eigen vector into 4x4 matrix for transform3d
        eigenVectors = np.insert(eigenVectors, 3, 0, axis=0)
        eigenVectors = np.insert(eigenVectors, 3, 0, axis=1)
        eigenVectors = eigenVectors.T
        eigenVectors = eigenVectors.flatten()
        # set eigen[3][3] to 1
        eigenVectors[15] = 1
        transformation  = Transform3D(eigenVectors)
        self.grabberElement.applyTransform(transformation, local=False)
        self.grabberElement.translate(position[0], position[1], position[2], local=False)
        self.grabberElement.applyTransform(self.pointCloudView.transform(), local=False)
        self.grabberElement.update()

        axisItem = gl.GLAxisItem(size=QVector3D(length, length, length))
        axisItem.applyTransform(self.grabberElement.transform(), local=False)
        self.addItem(axisItem, RenderGroup.Variable)
        self.grabberElement.setOpenGrabber(edgePair.getDistanceBetweenEdgePair())
        return
コード例 #15
0
def serial_data_qtplot(q2):
    kelowna_mag_raw = 367.5
    gain = 0.667
    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.opts['distance'] = 3000  # This is the initial zoom of the plot
    w.show()
    w.setWindowTitle('Sample magnetometer plots')
    # Define grids properties
    g = gl.GLGridItem()
    g.scale(500, 500, 500)
    w.addItem(g)

    # Define axes properties
    ax = gl.GLAxisItem()
    ax.setSize(1000, 1000, 1000)
    w.addItem(ax)

    md = gl.MeshData.sphere(rows=20, cols=20, radius=kelowna_mag_raw / gain)
    m4 = gl.GLMeshItem(meshdata=md,
                       smooth=False,
                       drawFaces=False,
                       drawEdges=True,
                       edgeColor=(1, 1, 1, 0.2))
    m4.translate(0, 10, 0)
    w.addItem(m4)

    # Maximum depth of queue. Increase this number to plot more data
    max_index = 10000
    index = 0
    p = np.zeros((max_index, 3))
    # White (1,1,1), Red(255,0,0), Blue(0,0,255), Green(0,128,0)
    sp = gl.GLScatterPlotItem(pos=p,
                              color=(0, 0, 255, 0.6),
                              size=50.0,
                              pxMode=False)
    w.addItem(sp)
    wait = 0
    while True:
        if not q2.empty():
            wait = 0
            pos = q2.get()
            p[index] = (pos[0][0], pos[0][1], pos[0][2]
                        )  # the calibrated readings from IMU1
            index += 1
            if index > max_index - 1:
                index = 0
                print "index reset"
            sp.setData(pos=p)
            app.processEvents()
        # If queue is empty,wait for data in queue. Exit if nothing
        else:
            if (wait > 20):
                break
            else:
                time.sleep(0.5)
                wait += 1
    print "No more data to plot, Exiting"
    sys.exit(app.exec_())
コード例 #16
0
def plotDetectedPointsGraph(data):
    if not hasattr(plotDetectedPointsGraph,"sp"):
        plotDetectedPointsGraph.sp = [None, None] # keep 2 copies
        plotDetectedPointsGraph.spIndex = 0;

    global widgetDetectedPoints
    if widgetDetectedPoints == None:
        widgetDetectedPoints = gl.GLViewWidget()
        widgetDetectedPoints.opts['distance'] = 20 # distance of camera from center
        widgetDetectedPoints.opts['fov'] = 60  # horizontal field of view in degrees
        widgetDetectedPoints.opts['azimuth'] = -75 # camera's azimuthal angle in degrees, 仰俯角
        widgetDetectedPoints.opts['elevation'] = 30 # camera's angle of elevation in degrees, 方位角
        widgetDetectedPoints.setGeometry(100, 100, 800, 800)
        widgetDetectedPoints.show()
        widgetDetectedPoints.setWindowTitle('Detected Points')
        gridX = gl.GLGridItem()
        gridX.rotate(0, 0, 1, 0)
        gridX.translate(0, 0, 0)
        widgetDetectedPoints.addItem(gridX)
        # center dot
        pos = np.array([0.0, 0.0, 0.0])
        size = np.array([0.2])
        color = np.array([1.0, 0.0, 0.0, 0.5])
        center  = gl.GLScatterPlotItem(pos=pos, size=size, color=color, pxMode=False)
        widgetDetectedPoints.addItem(center)
        # axis
        axis = gl.GLAxisItem(antialias=True, glOptions='translucent')
        axis.setSize(x=10, y=10, z=10)
        widgetDetectedPoints.addItem(axis)

    if data["type"] == MMWDEMO_OUTPUT_MSG_DETECTED_POINTS and len(data["x"]) > 0:
        x = data["x"]
        y = data["y"]
        z = data["z"]
        v = data["velocity"]
        s = data["snr"]
        n = data["noise"]

        pos = np.empty((len(data["x"]), 3))
        size = np.empty(len(data["x"]))
        color = np.empty((len(data["x"]), 4))
        for i in range(len(x)):
            pos[i] = (x[i], y[i], z[i])
            size[i] = s[i] / 2000
            if v[i]>= 0:
                color[i] = (0.0, v[i], 0.0, 1.0) #color (r,g,b,a)
            else:
                color[i] = (-v[i], 0.0, 0.0, 1.0) #color (r,g,b,a)

        sp1 = gl.GLScatterPlotItem(pos=pos, size=size, color=color, pxMode=False)
        #sp1.translate(0, 0, 0)

        if plotDetectedPointsGraph.sp[plotDetectedPointsGraph.spIndex] != None:
            sp2 = plotDetectedPointsGraph.sp[plotDetectedPointsGraph.spIndex]
            widgetDetectedPoints.removeItem(sp2)

        plotDetectedPointsGraph.sp[plotDetectedPointsGraph.spIndex] = sp1
        widgetDetectedPoints.addItem(sp1)
        plotDetectedPointsGraph.spIndex = (plotDetectedPointsGraph.spIndex + 1) % len(plotDetectedPointsGraph.sp)
コード例 #17
0
ファイル: plotting.py プロジェクト: KKalem/toolbox
def make_opengl_fig(title='OpenGL Figure'):

    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.show()
    w.setWindowTitle(title)
    g = gl.GLAxisItem()
    w.addItem(g)
    return w, app
コード例 #18
0
    def __init__(self, parent=None):
        QtWidgets.QDockWidget.__init__(self)
        self.plane_widget = PlaneWidget(mesh_path=MESH_PATH, parent=self)
        self.setFixedSize(1666, 1000)

        self.setWidget(self.plane_widget)
        self.isc_coord = gl.GLAxisItem()
        self.isc_coord.setSize(25, 25, 25)
        self.show()
コード例 #19
0
    def updateMeta(self, meta):

        _len_x = meta.max_x() - meta.min_x()
        _len_y = meta.max_y() - meta.min_y()
        _len_z = meta.max_z() - meta.min_z()

        self.setCenter((0, 0, 0))

        for _item in self._background_items:
            self.removeItem(_item)
            self._background_items = []

        # This section prepares the 3D environment:
        # Add an axis orientation item:
        self._axis = gl.GLAxisItem()
        # self._axis.setSize(x=_len_x, y=_len_y, z=_len_z)
        self._axis.setSize(x=_len_x, y=0.25 * _len_y, z=0.25 * _len_z)
        self.addItem(self._axis)

        # Add a set of grids along x, y, z:
        self._xy_grid = gl.GLGridItem()
        # Set the grid size to the number of voxels in x and y:
        self._xy_grid.setSize(x=meta.n_voxels_x(), y=meta.n_voxels_y(), z=0.0)
        # Scale the grid to the correct size:
        self._xy_grid.scale(x=meta.size_voxel_x(),
                            y=meta.size_voxel_y(),
                            z=1.0)
        self._xy_grid.translate(_len_x * 0.5, _len_y * 0.5, 0.0)

        self._yz_grid = gl.GLGridItem()
        self._yz_grid.setSize(x=meta.n_voxels_z(), y=meta.n_voxels_y())
        self._yz_grid.scale(x=meta.size_voxel_z(),
                            y=meta.size_voxel_y(),
                            z=1.0)
        self._yz_grid.rotate(-90, 0, 1, 0)
        self._yz_grid.translate(0, _len_y * 0.5, _len_z * 0.5)

        self._xz_grid = gl.GLGridItem()
        self._xz_grid.setSize(x=meta.n_voxels_x(), y=meta.n_voxels_z())
        self._xz_grid.scale(x=meta.size_voxel_x(),
                            y=meta.size_voxel_z(),
                            z=1.0)
        self._xz_grid.rotate(90, 1, 0, 0)
        self._xz_grid.translate(_len_x * 0.5, 0, _len_z * 0.5)

        self.addItem(self._xy_grid)
        self.addItem(self._yz_grid)
        self.addItem(self._xz_grid)

        self._background_items.append(self._axis)
        self._background_items.append(self._xy_grid)
        self._background_items.append(self._yz_grid)
        self._background_items.append(self._xz_grid)

        # Move the center of the camera to the center of the view:
        self.pan(_len_x * 0.5, _len_y * 0.5, _len_z * 0.5)
コード例 #20
0
 def __init__(self, parent=None):
     super().__init__(parent=parent)
     self._named_items = {}
     self.noRepeatKeys.append(QtCore.Qt.Key_W)
     self.noRepeatKeys.append(QtCore.Qt.Key_S)
     self.noRepeatKeys.append(QtCore.Qt.Key_A)
     self.noRepeatKeys.append(QtCore.Qt.Key_D)
     self.w_gl_axis = gl.GLAxisItem(
         size=None, antialias=True, glOptions='translucent')
     self.addItem(self.w_gl_axis)
コード例 #21
0
ファイル: lidarscan.py プロジェクト: raksdayal1/VLP16Lidar
def main():
    global lidarscatter, lid, frame_prev, frame_prev_len, ucount, flag
    IP = '192.168.1.71'  # IP of recving computer
    PORT_DATA = 2368
    PORT_POS = 8308

    #q_data = Queue(maxsize=0)
    #t_data = Thread(target = pull_data, args=(IP,PORT_DATA, q_data,))
    #t_parse = Thread(target = data_packet_parse, args=(q_data, q_frames,))
    #t_write = Thread(target = write_to_file, args=(FILE_NAME, q_frames,))

    #t_data.daemon = True
    #t_parse.daemon = True
    #t_write.daemon = True

    #t_data.start()
    #t_parse.start()
    #t_write.start()
    frame_prev = empty(shape=(0, 7), dtype=float)
    frame_prev_len = shape(frame_prev)[0]
    ucount = 0
    flag = False

    lid = LIDAR(IP, PORT_DATA)

    app = QtGui.QApplication([])
    w = gl.GLViewWidget()
    w.opts['distance'] = 20
    layout = QtGui.QGridLayout()

    w.setLayout(layout)
    w.show()
    w.setWindowTitle('GE-OSU Matrice 600 VLP16 Custom Lidar Scan')

    g = gl.GLGridItem()
    g.setSpacing(0.5, 0.5, 0.5)
    w.addItem(g)

    axes = gl.GLAxisItem(glOptions='opaque')
    w.addItem(axes)
    pos1 = zeros(shape=(10000, 3))
    lidarscatter = gl.GLScatterPlotItem(pos=pos1,
                                        color=(0.2, 0.4, 0.5, 0.4),
                                        size=2,
                                        pxMode=True)

    w.addItem(lidarscatter)

    t = QtCore.QTimer()
    t.timeout.connect(update)
    t.start(0)

    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
コード例 #22
0
    def show_3d_model(self):
        self.openGLWidget.setCameraPosition(distance=50, azimuth=-80)
        self.openGLWidget.show()
        # self.graphicsView.show()
        self.openGLWidget.setWindowTitle('pyqtgraph example: GLVolumeItem')

        # #b = gl.GLBoxItem()
        # #w.addItem(b)
        self.g = gl.GLGridItem()
        self.g.scale(2, 2, 1)
        # self.g.setSpacing(x=100, y=100, z=100, spacing=QVector3D(2, 2, 1000))
        self.openGLWidget.addItem(self.g)
        ax = gl.GLAxisItem()
        ax.setSize(x=25, y=25, z=25)
        self.openGLWidget.addItem(ax)
        yi = np.array([self.y[0]] * 100)
        xz = np.array(
            list(
                itertools.islice(self.graph_data.x_data,
                                 len(self.graph_data.x_data) - 100,
                                 len(self.graph_data.x_data))))
        pts = np.vstack([self.x, yi, xz]).transpose()
        self.pltx = gl.GLLinePlotItem(pos=pts, width=2, antialias=True)
        self.openGLWidget.addItem(self.pltx)
        yi = np.array([self.y[1]] * 100)
        yz = np.array(
            list(
                itertools.islice(self.graph_data.y_data,
                                 len(self.graph_data.y_data) - 100,
                                 len(self.graph_data.y_data))))
        pts = np.vstack([self.x, yi, yz]).transpose()
        self.plty = gl.GLLinePlotItem(pos=pts, width=2, antialias=True)
        self.openGLWidget.addItem(self.plty)
        yi = np.array([self.y[2]] * 100)
        zz = np.array(
            list(
                itertools.islice(self.graph_data.z_data,
                                 len(self.graph_data.z_data) - 100,
                                 len(self.graph_data.z_data))))
        pts = np.vstack([self.x, yi, zz]).transpose()
        self.pltz = gl.GLLinePlotItem(pos=pts, width=2, antialias=True)
        self.openGLWidget.addItem(self.pltz)
        vector_a = np.array([[0, 0, 0],
                             [
                                 self.graph_data.x_data[-1],
                                 self.graph_data.y_data[-1],
                                 self.graph_data.z_data[-1]
                             ]])
        self.plta = gl.GLLinePlotItem(pos=vector_a,
                                      color=pg.glColor((50, 50 * 1.3)),
                                      width=10,
                                      antialias=True)
        self.openGLWidget.addItem(self.plta)
コード例 #23
0
ファイル: hmm.py プロジェクト: adtera/Python-gpib-PCAR
    def __init__(self, parent=None):
        super(MyMainWindow, self).__init__(parent)
        self.setupUi(self)
        #self.c=Qwt5.QwtPlotCurve()
        #self.c.attach(self.plt)
        self.timer = QtCore.QTimer()
        self.timer.start(5.0)
        self.timer.timeout.connect(update)
        self.qtgraph.setLabel('left', 'Voltage', units='V')
        self.qtgraph.setLabel('bottom', 'Current', units='A')
        self.c1 = self.qtgraph.plot()
        self.c1.setPen((200, 200, 100))

        ## Add a grid to the 3D view
        g = gl.GLGridItem()
        g.scale(2, 2, 1)
        g.setDepthValue(
            10)  # draw grid after surfaces since they may be translucent
        self.pyqt3d.addItem(g)

        ## Animated example
        ## compute surface vertex data
        cols = 90
        rows = 100
        self.x = np.linspace(-8, 8, cols + 1).reshape(cols + 1, 1)
        self.y = np.linspace(-8, 8, rows + 1).reshape(1, rows + 1)
        d = (self.x**2 + self.y**2) * 0.1
        d2 = d**0.5 + 0.1

        ## precompute height values for all frames
        phi = np.arange(0, np.pi * 2, np.pi / 20.)
        self.z = np.sin(d[np.newaxis, ...] +
                        phi.reshape(phi.shape[0], 1, 1)) / d2[np.newaxis, ...]

        ## create a surface plot, tell it to use the 'heightColor' shader
        ## since this does not require normal vectors to render (thus we
        ## can set computeNormals=False to save time when the mesh updates)
        self.p4 = gl.GLSurfacePlotItem(x=self.x[:, 0],
                                       y=self.y[0, :],
                                       shader='heightColor',
                                       computeNormals=False,
                                       smooth=True)
        self.p4.shader()['colorMap'] = np.array(
            [0.2, 2, 0.5, 0.2, 1, 1, 0.2, 0, 2])
        #self.p4.translate(10, 10, 0)
        self.pyqt3d.addItem(self.p4)

        #self.v = gl.GLVolumeItem(d2)
        #self.v.translate(-50,-50,-100)
        #self.pyqt3d.addItem(self.v)

        ax = gl.GLAxisItem()
        self.pyqt3d.addItem(ax)
コード例 #24
0
    def setup_ui(self):
        self.gird = OpenGL.GLGridItem()
        self.addItem(self.gird)

        self.axis = OpenGL.GLAxisItem()
        self.addItem(self.axis)

        self.mesh = OpenGL.GLMeshItem()
        self.addItem(self.mesh)

        self.scene = OpenGL.GLMeshItem()
        self.addItem(self.scene)
コード例 #25
0
 def __init__(self, dataEngine, dataFormat, parent = None):
   DataView.__init__(self, dataEngine, dataFormat, parent)
   
   self.updateCount = 0
   
   self.setMinimumHeight(200)
   self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
   
   l = QtGui.QVBoxLayout(self)
   
   self.glWidget = MyGLViewWidget(self)
   
   l.addWidget(self.glWidget)
   
   hlayout = QtGui.QHBoxLayout()
   hlayout.addWidget(QtGui.QLabel('Depth Threshold:'))
   
   self.spanSlider = QxtSpanSlider()
   self.spanSlider.floatLowerPositionChanged.connect(self.updateLowerLevel)
   self.spanSlider.floatUpperPositionChanged.connect(self.updateUpperLevel)
   hlayout.addWidget(self.spanSlider)
   
   l.addLayout(hlayout)
   
   self.glWidget.opts['distance'] = 20
   
   self.gridItem = gl.GLGridItem(size = QtGui.QVector3D(10,10,1))
   self.glWidget.addItem(self.gridItem)
   
   self.axisItem = gl.GLAxisItem()
   self.axisItem.setSize(3,3,3)
   self.glWidget.addItem(self.axisItem)
   
   pos = np.array([[0., 0., 0.]])
   color = np.array([[0., 0., 0., 0.]])
   
   self.scatterItem = gl.GLScatterPlotItem(pxMode = True, size = 2, pos = pos, color = color)
   self.glWidget.addItem(self.scatterItem)
   
   self.glWidget.resetCamera()
   
   self.glWidget.export.connect(self.exportImage)
   
   DataView.communicator.setCurrentPoint2D.connect(self.setCenter, QtCore.Qt.QueuedConnection)
   
   DataView.communicator.thresholdsChanged.connect(self.setThresholds, QtCore.Qt.QueuedConnection)
   
   self.currentPCF = None
   
   self.dataEngine.getDepthCameraController().started.connect(self.streamStarted)
   
   self.setSpanKeyModifier(QtCore.Qt.ControlModifier)
コード例 #26
0
    def __init__(self):
        self.app = QtGui.QApplication(sys.argv)

        jsonpickle.ext.numpy.register_handlers()

        mw = QtGui.QMainWindow()
        ui = Ui_MainWindow()
        ui.setupUi(mw)

        #Obtain DesktopWidget to gain screen sizes
        dw = QtGui.QDesktopWidget()
        screen = dw.availableGeometry()

        #Resize main window to 90% of the screen width/height
        mw.resize(screen.size() * 0.9)

        #Recenter main window
        frame = mw.frameGeometry()
        frame.moveCenter(screen.center())
        mw.move(frame.topLeft())

        pw = gl.GLViewWidget(ui.centralwidget)
        ui.gridLayout.replaceWidget(ui.plotWidget, pw)
        ui.plotWidget.hide()
        ui.plotWidget = pw

        self.ui = ui
        self.mw = mw
        self.pw = pw

        self.tree = None
        self.paths = None
        self.seedAmt = None
        self.state = -1

        mw.setWindowTitle("Hierarchical Visualizer")

        pw.setSizePolicy(QtGui.QSizePolicy.Expanding,
                         QtGui.QSizePolicy.Expanding)

        axis = gl.GLAxisItem()
        xText = glt.GLTextItem(GLViewWidget=self.pw, X=1, Y=0, Z=0, text="X")
        yText = glt.GLTextItem(GLViewWidget=self.pw, X=0, Y=1, Z=0, text="Y")
        zText = glt.GLTextItem(GLViewWidget=self.pw, X=0, Y=0, Z=1, text="Z")

        self.pw.addItem(axis)
        self.pw.addItem(xText)
        self.pw.addItem(yText)
        self.pw.addItem(zText)

        self.connectSlots()
コード例 #27
0
    def add_board(self):
        verts = np.array([
            [5, -3, 2],  # front-right-top
            [5, 3, 2],  # front-left-top
            [-5, -3, 2],  # back-right-top
            [-5, 3, 2],  # back-left-top
            [5, -3, -1],  # front-right-bottom
            [5, 3, -1],  # front-left-bottom
            [-5, -3, -1],  # back-right-bottom
            [-5, 3, -1],  # back-left-bottom
        ])
        faces = np.array([
            [0, 1, 2],  # top
            [1, 2, 3],  # top
            [4, 5, 6],  # bottom
            [5, 6, 7],  # bottom
            [0, 2, 4],  # right
            [2, 4, 6],  # right
            [1, 3, 5],  # left
            [3, 5, 7],  # left
            [0, 1, 4],  # front
            [1, 4, 5],  # front
            [2, 3, 6],  # back
            [3, 6, 7],  # back
        ])
        colors = np.array([
            [1, 1, 1, 1],  # top
            [1, 1, 1, 1],  # top
            [1, 1, 0, 1],  # bottom
            [1, 1, 0, 1],  # bottom
            [1, 0, 0, 1],  # right
            [1, 0, 0, 1],  # right
            [0, 1, 0, 1],  # left
            [0, 1, 0, 1],  # left
            [0, 0, 1, 1],  # front
            [0, 0, 1, 1],  # front
            [0, 1, 1, 1],  # back
            [0, 1, 1, 1],  # back
        ])

        self.board = gl.GLMeshItem(vertexes=verts,
                                   faces=faces,
                                   faceColors=colors,
                                   smooth=False,
                                   drawEdges=False)
        self.addItem(self.board)

        self.axis = gl.GLAxisItem()
        self.axis.setSize(x=10, y=10, z=10)
        self.addItem(self.axis)
コード例 #28
0
    def __init__(self,
                 emitters=None,
                 middles=None,
                 detectors=None,
                 radius=6,
                 index_refraction=.2):

        super(Main3DView, self).__init__()
        self.addItem(gl.GLAxisItem())
        self.index_refraction = index_refraction
        self.sphere_radius = radius

        # Draw sphere first so it goes under everything else
        self.addItem(Sphere(Point(0, 0, 0), self.sphere_radius))
コード例 #29
0
def plot3d(xs, ys, zs, colors, start=0, end=-1, step=1):
    w = gl.GLViewWidget()
    for i, x in enumerate(xs):
        sampled_x = x[start:end:step]
        sampled_y = ys[i][start:end:step] - ys[i][0]
        z = np.ones(len(sampled_x)) * zs[i]
        plt = plot_line(sampled_x, sampled_y, z, color=colors[i])
        w.addItem(plt)
    #add_grids(w)
    ax = gl.GLAxisItem()

    w.addItem(ax)
    ##w.pan(0,0,0)
    return w
コード例 #30
0
ファイル: gcs_graphing.py プロジェクト: korr237i/stm32f0_mpu
    def __init__(self, mesh_path, *args, **kwargs):
        super(PlaneWidget, self).__init__(*args, **kwargs)
        self.setCameraPosition(distance=15)
        self.setBackgroundColor([120, 120, 120, 0])
        g = gl.GLGridItem()
        g.scale(2, 2, 1)
        g.setSize(350, 350, 350)
        self.addItem(g)

        isc_coord = gl.GLAxisItem()
        isc_coord.setSize(350, 350, 350)
        isc_coord.translate(0, 0, 0.5)
        self.addItem(isc_coord)

        self.plane_axis = gl.GLAxisItem()
        self.plane_axis.setSize(x=300, y=300, z=300)
        self.addItem(self.plane_axis)

        verts = self._get_mesh_points(mesh_path)
        faces = np.array([(i, i+1, i+2,) for i in range(0, len(verts), 3)])
        colors = np.array([(0.0, 1.0, 0.0, 1.0,) for i in range(0, len(verts), 3)])
        self.mesh = gl.GLMeshItem(vertexes=verts, faces=faces, faceColors=colors, smooth=False, shader='shaded')
        self.addItem(self.mesh)