예제 #1
0
def main():
    # Create OpenGL window in single line
    pangolin.CreateWindowAndBind('Main', 640, 480)
    gl.glEnable(gl.GL_DEPTH_TEST)

    # Define Projection and initial ModelView matrix
    scam = pangolin.OpenGlRenderState(
        pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100),
        pangolin.ModelViewLookAt(-2, 2, -2, 0, 0, 0,
                                 pangolin.AxisDirection.AxisY))
    handler = pangolin.Handler3D(scam)

    # Create Interactive View in window
    dcam = pangolin.CreateDisplay()
    dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0)
    dcam.SetHandler(handler)

    # Data logger object
    log = pangolin.DataLog()

    # Optionally add named labels
    labels = ['sin(t)', 'cos(t)', 'sin(t)+cos(t)']
    log.SetLabels(labels)

    # OpenGL 'view' of data. We might have many views of the same data.
    tinc = 0.03
    plotter = pangolin.Plotter(log, 0.0, 6.0 * np.pi / tinc, -2.0, 2.0,
                               np.pi / (6 * tinc), 0.5)
    plotter.SetBounds(0.05, 0.3, 0.0, 0.4)
    plotter.Track('$i')

    # Add some sample annotations to the plot
    plotter.AddMarker(pangolin.Marker.Vertical, -1000,
                      pangolin.Marker.LessThan,
                      pangolin.Colour.Blue().WithAlpha(0.2))
    plotter.AddMarker(pangolin.Marker.Horizontal, 100,
                      pangolin.Marker.GreaterThan,
                      pangolin.Colour.Red().WithAlpha(0.2))
    plotter.AddMarker(pangolin.Marker.Horizontal, 10, pangolin.Marker.Equal,
                      pangolin.Colour.Green().WithAlpha(0.2))

    pangolin.DisplayBase().AddDisplay(plotter)

    t = 0
    while not pangolin.ShouldQuit():
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        # Plot line
        log.Log(np.sin(t), np.cos(t), np.sin(t) + np.cos(t))
        t += tinc

        gl.glClearColor(1.0, 1.0, 1.0, 1.0)
        dcam.Activate(scam)

        # Render OpenGL 3D Cube
        pangolin.glDrawColouredCube()

        pangolin.FinishFrame()
예제 #2
0
    def viewer_init(self):
        w, h = (1024, 768)
        f = 2000  #420

        pangolin.CreateWindowAndBind("Visual Odometry Trajectory Viewer", w, h)
        gl.glEnable(
            gl.GL_DEPTH_TEST
        )  #prevents point overlapping issue, check out fake-stereo's issues for more info

        # Projection and ModelView Matrices
        self.scam = pangolin.OpenGlRenderState(
            pangolin.ProjectionMatrix(w, h, f, f, w // 2, h // 2, 0.1, 100000),
            pangolin.ModelViewLookAt(0, -50.0, -10.0, 0.0, 0.0, 0.0, 0.0, -1.0,
                                     0.0))  #pangolin.AxisDirection.AxisY))
        self.handler = pangolin.Handler3D(self.scam)

        # Interactive View in Window
        self.dcam = pangolin.CreateDisplay()
        self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -w / h)
        self.dcam.SetHandler(self.handler)
        self.dcam.Activate()

        #Image viewport

        self.dimg = pangolin.Display('image')
        self.dimg.SetBounds(0, self.h_i / h, 1 - self.w_i / w, 1.0, -w / h)
        self.dimg.SetLock(pangolin.Lock.LockLeft, pangolin.Lock.LockTop)

        self.texture = pangolin.GlTexture(self.w_i, self.h_i, gl.GL_RGB, False,
                                          0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE)
        self.img = np.ones((self.h_i, self.w_i, 3), 'uint8') * 255

        # Translation error graph
        self.log = pangolin.DataLog()
        self.labels = ['error_t', 'error_r']  #, "error_euclidean"]
        self.log.SetLabels(self.labels)

        self.plotter = pangolin.Plotter(self.log, 0.0, 1500, -1500, 2500, 10,
                                        0.5)
        self.plotter.SetBounds(0.0, self.h_i / h, 0.0, 1 - self.w_i / w,
                               -w / h)

        self.plotter.Track("$i", "")

        pangolin.DisplayBase().AddDisplay(self.plotter)
        self.errorlog_r, self.errorlog_t = [], []
예제 #3
0
def main():
    # Create OpenGL window in single line
    pangolin.CreateWindowAndBind('Main', 640, 480)

    # Data logger object
    log = pangolin.DataLog()

    # Optionally add named labels
    labels = ['sin(t)', 'cos(t)', 'sin(t)+cos(t)']
    log.SetLabels(labels)

    # OpenGL 'view' of data. We might have many views of the same data.
    tinc = 0.03
    plotter = pangolin.Plotter(log, 0.0, 4.0 * np.pi / tinc, -2.0, 2.0,
                               np.pi / (4 * tinc), 0.5)
    plotter.SetBounds(0.0, 1.0, 0.0, 1.0)
    plotter.Track('$i')

    # Add some sample annotations to the plot
    plotter.AddMarker(pangolin.Marker.Vertical, -1000,
                      pangolin.Marker.LessThan,
                      pangolin.Colour.Blue().WithAlpha(0.2))
    plotter.AddMarker(pangolin.Marker.Horizontal, 100,
                      pangolin.Marker.GreaterThan,
                      pangolin.Colour.Red().WithAlpha(0.2))
    plotter.AddMarker(pangolin.Marker.Horizontal, 10, pangolin.Marker.Equal,
                      pangolin.Colour.Green().WithAlpha(0.2))

    pangolin.DisplayBase().AddDisplay(plotter)

    t = 0
    while not pangolin.ShouldQuit():
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        log.Log(np.sin(t), np.cos(t), np.sin(t) + np.cos(t))
        t += tinc

        pangolin.FinishFrame()
예제 #4
0
def main():
    pangolin.ParseVarsFile('app.cfg')

    pangolin.CreateWindowAndBind('Main', 640, 480)
    gl.glEnable(gl.GL_DEPTH_TEST)

    scam = pangolin.OpenGlRenderState(
        pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.1, 1000),
        pangolin.ModelViewLookAt(0, 0.5, -3, 0, 0, 0,
                                 pangolin.AxisDirection.AxisY))
    handler3d = pangolin.Handler3D(scam)

    dcam = pangolin.CreateDisplay()
    dcam.SetBounds(0.0, 1.0, 180 / 640., 1.0, -640.0 / 480.0)
    # dcam.SetBounds(pangolin.Attach(0.0),     pangolin.Attach(1.0),
    # pangolin.Attach.Pix(180), pangolin.Attach(1.0), -640.0/480.0)

    dcam.SetHandler(pangolin.Handler3D(scam))

    panel = pangolin.CreatePanel('ui')
    panel.SetBounds(0.0, 1.0, 0.0, 180 / 640.)

    button = pangolin.VarBool('ui.Button', value=False, toggle=False)
    checkbox = pangolin.VarBool('ui.Checkbox', value=False, toggle=True)
    float_slider = pangolin.VarFloat('ui.Float', value=3, min=0, max=5)
    float_log_slider = pangolin.VarFloat('ui.Log_scale var',
                                         value=3,
                                         min=1,
                                         max=1e4,
                                         logscale=True)
    int_slider = pangolin.VarInt('ui.Int', value=2, min=0, max=5)
    int_slave_slider = pangolin.VarInt('ui.Int_slave', value=2, toggle=False)

    save_window = pangolin.VarBool('ui.Save_Window', value=False, toggle=False)
    save_cube = pangolin.VarBool('ui.Save_Cube', value=False, toggle=False)
    record_cube = pangolin.VarBool('ui.Record_Cube', value=False, toggle=False)

    def reset():
        #float_slider.SetVal(0.5)
        print('You typed ctrl-r or pushed reset')

    # Reset = SetVarFunctor(float_slider, 0.5)
    # reset = pangolin.VarFunc('ui.Reset', reset)
    # pangolin.RegisterKeyPressCallback(int(pangolin.PANGO_CTRL) + ord('r'), reset)      # segfault
    # pangolin.RegisterKeyPressCallback(int(pangolin.PANGO_CTRL) + ord('b'), pangolin.SetVarFunctorFloat('ui.Float', 4.5))      # segfault
    # pangolin.RegisterKeyPressCallback(int(pangolin.PANGO_CTRL) + ord('b'), SetVarFunctor(float_slider, 4.5))      # segfault

    while not pangolin.ShouldQuit():
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

        if pangolin.Pushed(button):
            print('You Pushed a button!')

        if checkbox.Get():
            int_slider.SetVal(int(float_slider))
        int_slave_slider.SetVal(int_slider)

        if pangolin.Pushed(save_window):
            pangolin.SaveWindowOnRender("window")

        if pangolin.Pushed(save_cube):
            pangolin.SaveWindowOnRender("cube")

        if pangolin.Pushed(record_cube):
            pangolin.DisplayBase().RecordOnRender(
                "ffmpeg:[fps=50,bps=8388608,unique_filename]//screencap.avi")

        dcam.Activate(scam)
        gl.glColor3f(1.0, 1.0, 1.0)
        pangolin.glDrawColouredCube()
        pangolin.FinishFrame()