def main(): pango.CreateWindowAndBind('point cloud cube render', 640, 480) # Projection and ModelView Matrices scam = pango.OpenGlRenderState( pango.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100), pango.ModelViewLookAt(-1, -1, -1, 0, 0, 0, pango.AxisDirection.AxisY)) handler = pango.Handler3D(scam) # Interactive View in Window disp_cam = pango.CreateDisplay() disp_cam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) disp_cam.SetHandler(handler) # Create a random point cloud pts = np.random.random((100, 3)) * 10 # Color matrix based on point location colors = np.zeros((len(pts), 3)) colors[:, :] = 1. - pts[:, :] / 10 #colors[:] = [1.0, 0.0, 0.0] while not pango.ShouldQuit(): # Clear screen gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.15, 0.15, 0.15, 0.0) disp_cam.Activate(scam) # Draw Points gl.glPointSize(5) gl.glColor3f(0.0, 1.0, 0.0) pango.DrawPoints(pts, colors) # Finish Drawing pango.FinishFrame()
def pangolin_init(w, h): """ DESCRIPTION: init pangolin. """ W, H = w, h pangolin.CreateWindowAndBind('Main', W, H) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(W, H, 420, 420, W // 2, H // 2, 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, W / H) dcam.SetHandler(handler) # Create area to show video stream dimg = pangolin.Display('image') dimg.SetBounds( 1.0, 0.66, 0, 0.33, W / H) # (debut hauteur, fin hauteur, debut largeur, fin largeur, ratio) dimg.SetLock(pangolin.Lock.LockLeft, pangolin.Lock.LockTop) return scam, dcam, dimg
def DISPLAY(): import numpy as np import OpenGL.GL as gl import pangolin 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) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) dcam.Activate(scam) # Render OpenGL Cube pangolin.glDrawColouredCube() # Draw Point Cloud points = np.random.random((100000, 3)) * 10 gl.glPointSize(2) gl.glColor3f(1.0, 0.0, 0.0) pangolin.DrawPoints(points) pangolin.FinishFrame()
def LookAt(self, dest): self.viewMat = pangolin.ModelViewLookAt(self.eye[0], self.eye[1], self.eye[2], dest[0], dest[1], dest[2], pangolin.AxisDirection.AxisY) # self.up[0], self.up[1], self.up[2]) self._rendered_cam = pangolin.OpenGlRenderState(self.projectionMat, self.viewMat) return self.viewMat
def visualize_3D(p3D): pangolin.CreateWindowAndBind('main', 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) 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) dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) dcam.SetHandler(handler) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) dcam.Activate(scam) #gl.glPointSize(5); #gl.glColor3f(0.0,0.0,1.0); #pangolin.DrawPoints(p3D); # Attempt to draw camera gl.glLineWidth(2) gl.glColor3f(1.0, 0.0, 0.0) #pose = np.identity(4); pose = (np.hstack((pose1.T, np.zeros((4, 1))))).T pangolin.DrawCamera(pose, 0.5, 0.75, 0.8) pangolin.FinishFrame()
def main(): 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, 200), 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) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) dcam.Activate(scam) # Draw Point Cloud points = np.random.random((10000, 3)) colors = np.zeros((len(points), 3)) colors[:, 1] = 1 - points[:, 0] colors[:, 2] = 1 - points[:, 1] colors[:, 0] = 1 - points[:, 2] points = points * 3 + 1 gl.glPointSize(5) pangolin.DrawPoints(points, colors) pangolin.FinishFrame()
def main(showSemSegmentation=False): # create window 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, 50), pangolin.ModelViewLookAt(0, 0, -.01, 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) points, colors, sem = getPointsAndColors("000020.png") # If we want to show the semantic segmentations if showSemSegmentation: colors = colors * 0.5 + sem * 0.5 while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) dcam.Activate(scam) gl.glPointSize(2) gl.glColor3f(1.0, 0.0, 0.0) # access numpy array directly(without copying data), array should be contiguous. pangolin.DrawPoints(points, colors) pangolin.FinishFrame()
def main(): 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.AxisY)) tree = pangolin.Renderable() tree.Add(pangolin.Axis()) # Create Interactive View in window handler = pangolin.SceneHandler(tree, scam) dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) dcam.SetHandler(handler) def draw(view): view.Activate(scam) tree.Render() dcam.SetDrawFunction(draw) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) # or # dcam.Activate(scam) # tree.Render() pangolin.FinishFrame()
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()
def handler_cam(scam, attrs): if attrs: look = attrs.get('look', [0, -70, 70]) at = attrs.get('at', [0, 0, 0]) up = attrs.get('up', pangolin.AxisZ) scam.SetModelViewMatrix( pangolin.ModelViewLookAt(look[0], look[1], look[2], at[0], at[1], at[2], up)) else: pass
def draw_init(self): pangolin.CreateWindowAndBind(self.name, 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) self.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(self.scam) self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) self.dcam.SetHandler(handler)
def work(q, qclose, w=960, h=540): pangolin.CreateWindowAndBind('pangolin', w, h) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(w, h, 420, 420, w // 2, h // 2, 0.2, 10000), pangolin.ModelViewLookAt(-2, -2, -8, 0, 0, 0, pangolin.AxisDirection.AxisNegY)) handler = pangolin.Handler3D(scam) # Create Interactive View in window dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -w / h) dcam.SetHandler(handler) pose = np.eye(4) opath = np.zeros((0, 3)) opts = np.zeros((2, 3)) colors = np.zeros((2, 3)) while not pangolin.ShouldQuit(): if not qclose.empty(): if qclose.get(): pangolin.Quit() if not q.empty(): pose, opath, opts, colors = q.get() colors /= 256.0 gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.0, 0.0, 0.0, 1.0) dcam.Activate(scam) # draw_axes() # Draw optimized cloud gl.glPointSize(2) gl.glColor3f(0.5, 0.8, 0.5) pangolin.DrawPoints(opts, colors) # Draw camera gl.glLineWidth(1) gl.glColor3f(0.4, 0.4, 0.4) pangolin.DrawCamera(pose, 10, 1, 1) # Optimized path if len(opath) > 2: gl.glLineWidth(1) gl.glColor3f(0.4, 0.4, 0.4) pangolin.DrawLine(np.array(opath)) pangolin.FinishFrame()
def main(self): ''' Main function: Creates the user window and side bar with a button. This button is used to toggle between normal point cloud and downsampled point cloud ''' pangolin.CreateWindowAndBind('Sample Toggle App', 1280, 960) #Set sindow size and name gl.glEnable( gl.GL_DEPTH_TEST ) #This is enabled to allow for user to move/rotate 3D image with mouse #Define render object SampleToggling.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(SampleToggling.scam) #Add viewpoint object SampleToggling.dcam = pangolin.CreateDisplay() SampleToggling.dcam.SetBounds(0.0, 1.0, 180 / 640., 1.0, -640.0 / 480.0) SampleToggling.dcam.SetHandler(pangolin.Handler3D(SampleToggling.scam)) #Create the side panel panel = pangolin.CreatePanel('buttonPanel') panel.SetBounds(0.0, 1.0, 0.0, 180 / 640.) gl.glPointSize(1) #Set the size of each point on the point cloud button = pangolin.VarBool('buttonPanel.Sampling Toggle Button', value=False, toggle=False) #Create a simple button #Read the .ply file and convert it into a numpy array so it can be understood by pangolin pointCloudOrigional = o3d.io.read_point_cloud("bunny.ply") pointCloudOrigionalArray = np.asarray(pointCloudOrigional.points) #Down sample this read .ply file and then convert that into a numpy array pointCloudDownSampled = voxel_down_sample(pointCloudOrigional, voxel_size=0.008) pointCloudDownSampledArray = np.asarray(pointCloudDownSampled.points) #Zoom the pointCloud so it is easy for user to see pointCloudOrigionalZoomed = pointCloudOrigionalArray * self.zoomCoefficient pointCloudSampledZoomed = pointCloudDownSampledArray * self.zoomCoefficient #Run a loop until the program is quit, toggling image each time button is pressed. while not pangolin.ShouldQuit(): self.drawPoints(pointCloudOrigionalZoomed) if pangolin.Pushed(button): while not pangolin.Pushed(button): self.drawPoints(pointCloudSampledZoomed)
def viewer_init(self, w, h): pangolin.CreateWindowAndBind('Main', w, h) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(w, h, 420, 420, w // 2, h // 2, 0.2, 10000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -w / h) self.dcam.SetHandler(self.handler) self.darr = None
def init_thread(self): pangolin.CreateWindowAndBind('Main', 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 1000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) self.dcam.SetHandler(self.handler)
def viewer_init(self): pangolin.CreateWindowAndBind('Main', self.width, self.Height) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(self.width, self.Height, 420, 420, self.width // 2, self.Height // 2, 0.2, 1000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -self.width / self.Height) self.dcam.SetHandler(self.handler)
def run(dq, name): pangolin.CreateWindowAndBind(name, 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, 2000), pangolin.ModelViewLookAt(-70, -70, 70, 0, 0, 0, pangolin.AxisDirection.AxisZ)) # Create Interactive View in window dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) dcam.SetHandler(pangolin.Handler3D(scam)) should_quit = False handlers = { 'pts': VisualizerPangoV2.handler_pts, 'boxes_3d': VisualizerPangoV2.handler_bboxes3d, 'boxes_3d_center': VisualizerPangoV2.handler_bboxes3d_center, 'lines': VisualizerPangoV2.handler_lines, 'boxes_2d': VisualizerPangoV2.handler_bboxes2d } targets = {} for k in handlers: targets[k] = {} while not (pangolin.ShouldQuit() or should_quit): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) dcam.Activate(scam) pangolin.glDrawColouredCube() while not dq.empty(): o = dq.get() if type(o) is str: if o == 'quit': should_quit = True break if type(o) is tuple: op, tp, k, v = o if tp == 'cam': VisualizerPangoV2.handler_cam(scam, v) else: if op == 'reset': targets[tp][k] = [v] elif op == 'add': if k not in targets[tp]: targets[tp][k] = [] targets[tp][k].append(v) for t in handlers: for k in targets[t]: for v in targets[t][k]: handlers[t](*v) pangolin.FinishFrame()
def main(): # Create OpenGL window in single line pangolin.CreateWindowAndBind('Main', 640, 480) # 3D Mouse handler requires depth testing to be enabled gl.glEnable(gl.GL_DEPTH_TEST) scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.1, 1000), pangolin.ModelViewLookAt(-1, 1, -1, 0, 0, 0, pangolin.AxisDirection.AxisY)) # Aspect ratio allows us to constrain width and height whilst fitting within specified # bounds. A positive aspect ratio makes a view 'shrink to fit' (introducing empty bars), # whilst a negative ratio makes the view 'grow to fit' (cropping the view). dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) dcam.SetHandler(pangolin.Handler3D(scam)) # This view will take up no more than a third of the windows width or height, and it # will have a fixed aspect ratio to match the image that it will display. When fitting # within the specified bounds, push to the top-left (as specified by SetLock). dimg = pangolin.Display('image') dimg.SetBounds(2. / 3, 1.0, 0.0, 1. / 3, 640. / 480) dimg.SetLock(pangolin.Lock.LockLeft, pangolin.Lock.LockTop) w, h = 64, 48 texture = pangolin.GlTexture(w, h, gl.GL_RGB, False, 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE) # Default hooks for exiting (Esc) and fullscreen (tab). while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.95, 0.95, 0.95, 1.0) dcam.Activate(scam) gl.glColor3f(1.0, 1.0, 1.0) pangolin.glDrawColouredCube() # Set some random image data and upload to GPU image = random_image(w, h) texture.Upload(image, gl.GL_RGB, gl.GL_UNSIGNED_BYTE) # display the image dimg.Activate() gl.glColor3f(1.0, 1.0, 1.0) texture.RenderToViewport() pangolin.FinishFrame()
def __init__(self, K): self.K = K self.K_inverse = np.linalg.inv(self.K) # plot 3d self.window = pangolin.CreateWindowAndBind('3D SPACE', 1200, 800) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 100), pangolin.ModelViewLookAt(1, -1, -4, 1, 1, 1, pangolin.AxisDirection.AxisZ)) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) self.dcam.SetHandler(self.handler)
def viewer_init(self, w, h): # pangolin.ParseVarsFile('app.cfg') pangolin.CreateWindowAndBind('Map Viewer', w, h) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(w, h, 500, 500, 512, 389, 0.1, 1000), pangolin.ModelViewLookAt(0, -10, -20, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, kUiWidth / w, 1.0, -w / h) self.dcam.SetHandler(pangolin.Handler3D(self.scam)) # hack to avoid small Pangolin, no idea why it's *2 # self.dcam.Resize(pangolin.Viewport(0,0,w*2,h*2)) # self.dcam.Activate() self.panel = pangolin.CreatePanel('ui') self.panel.SetBounds(0.0, 1.0, 0.0, kUiWidth / w) self.do_follow = True self.draw_cameras = True #self.button = pangolin.VarBool('ui.Button', value=False, toggle=False) self.checkboxFollow = pangolin.VarBool('ui.Follow', value=True, toggle=True) self.checkboxCams = pangolin.VarBool('ui.Draw Cameras', value=True, toggle=True) self.checkboxGrid = pangolin.VarBool('ui.Grid', value=True, toggle=True) #self.float_slider = pangolin.VarFloat('ui.Float', value=3, min=0, max=5) #self.float_log_slider = pangolin.VarFloat('ui.Log_scale var', value=3, min=1, max=1e4, logscale=True) self.int_slider = pangolin.VarInt('ui.Point Size', value=kDefaultPointSize, min=1, max=10) self.pointSize = self.int_slider.Get() self.Twc = pangolin.OpenGlMatrix() self.Twc.SetIdentity()
def viewer_init(self, w, h): # pangolin.ParseVarsFile('app.cfg') pangolin.CreateWindowAndBind('Map Viewer', w, h) gl.glEnable(gl.GL_DEPTH_TEST) viewpoint_x = 0 viewpoint_y = -40 viewpoint_z = -80 viewpoint_f = 1000 self.proj = pangolin.ProjectionMatrix(w, h, viewpoint_f, viewpoint_f, w//2, h//2, 0.1, 5000) self.look_view = pangolin.ModelViewLookAt(viewpoint_x, viewpoint_y, viewpoint_z, 0, 0, 0, 0, -1, 0) self.scam = pangolin.OpenGlRenderState(self.proj, self.look_view) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, kUiWidth/w, 1.0, -w/h) self.dcam.SetHandler(pangolin.Handler3D(self.scam)) self.panel = pangolin.CreatePanel('ui') self.panel.SetBounds(0.0, 1.0, 0.0, kUiWidth/w) self.do_follow = True self.is_following = True self.draw_cameras = True self.draw_covisibility = True self.draw_spanning_tree = True self.draw_loops = True #self.button = pangolin.VarBool('ui.Button', value=False, toggle=False) self.checkboxFollow = pangolin.VarBool('ui.Follow', value=True, toggle=True) self.checkboxCams = pangolin.VarBool('ui.Draw Cameras', value=True, toggle=True) self.checkboxCovisibility = pangolin.VarBool('ui.Draw Covisibility', value=True, toggle=True) self.checkboxSpanningTree = pangolin.VarBool('ui.Draw Tree', value=True, toggle=True) self.checkboxGrid = pangolin.VarBool('ui.Grid', value=True, toggle=True) self.checkboxPause = pangolin.VarBool('ui.Pause', value=False, toggle=True) #self.float_slider = pangolin.VarFloat('ui.Float', value=3, min=0, max=5) #self.float_log_slider = pangolin.VarFloat('ui.Log_scale var', value=3, min=1, max=1e4, logscale=True) self.int_slider = pangolin.VarInt('ui.Point Size', value=kDefaultPointSize, min=1, max=10) self.pointSize = self.int_slider.Get() self.Twc = pangolin.OpenGlMatrix() self.Twc.SetIdentity()
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 = [], []
def viewer_init(self, W, H): pangolin.CreateWindowAndBind('Map View', W, H) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(W, H, 420, 420, W//2, H//2, 0.2, 10000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # create the interactive window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, W/H) self.dcam.SetHandler(self.handler) # avoid small Pangolin self.dcam.Resize(pangolin.Viewport(0, 0, W*2, H*2)) self.dcam.Activate()
def run(self): pangolin.CreateWindowAndBind(self.win_name, 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(640, 480, 420, 420, 320, 240, 0.2, 1000), pangolin.ModelViewLookAt(2, -10, -30, 0, 0, 0, pangolin.AxisNegY)) self.tree = pangolin.Renderable() self.tree.Add(pangolin.Axis()) self.handler = pangolin.SceneHandler(self.tree, self.scam) self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) self.dcam.SetHandler(self.handler) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(1.0, 1.0, 1.0, 1.0) self.dcam.Activate(self.scam) self.tree.Render() self.data_lock.acquire() if self.poses: gl.glPointSize(5) gl.glColor3f(*self.cam_color) for pose in self.poses: pangolin.DrawPoints(pose[1].T) if self.map_pts is not None: gl.glPointSize(2) gl.glColor3f(*self.map_pts_color) pangolin.DrawPoints(self.map_pts) if self.new_pts_obs is not None: cur_pos = self.poses[-1] cam_centers = np.repeat(cur_pos[1].T, self.new_pts_obs.shape[0], axis=0) gl.glLineWidth(1) gl.glColor3f(0.0, 0.0, 1.0) pangolin.DrawLines(cam_centers, self.new_pts_obs) self.data_lock.release() time.sleep(0.02) pangolin.FinishFrame()
def viewer_init(self, w, h): pangolin.CreateWindowAndBind('Map Viewer', w, h) gl.glEnable(gl.GL_DEPTH_TEST) self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(w, h, 420, 420, w // 2, h // 2, 0.2, 10000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # Create 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) # hack to avoid small Pangolin, no idea why it's *2 self.dcam.Resize(pangolin.Viewport(0, 0, w * 2, h * 2)) self.dcam.Activate()
def run_viewer(q): w, h = 1024, 768 f = 2000 pango.CreateWindowAndBind('g2o', w, h) gl.glEnable(gl.GL_DEPTH_TEST) cam = pango.OpenGlRenderState( pango.ProjectionMatrix(w, h, f, f, w // 2, h // 2, 0.1, 100000), pango.ModelViewLookAt( 1000., 1000., 1000., 0., 0., 0., 0., -1., 0., )) handler = pango.Handler3D(cam) dcam = pango.CreateDisplay() dcam.SetBounds(0., 1., 0., 1., -w / h) dcam.SetHandler(handler) dcam.Activate() # nodes = [x.estimate().matrix() for x in optimizer.vertices().values()] # nodes = np.array(nodes) edges = None while not pango.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.15, 0.15, 0.15, 0.0) dcam.Activate(cam) try: edges = q.get(block=False) except queue.Empty: pass if edges is not None: gl.glLineWidth(1) gl.glColor3f(0.2, 1.0, 0.2) pango.DrawLines(edges[:, 0], edges[:, 1]) pango.FinishFrame()
def main(): w, h = 640, 480 pangolin.CreateWindowAndBind('Main', 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) # Create Interactive View in window scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(w, h, 420, 420, w//2, h//2, 0.2, 10000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) handler = pangolin.Handler3D(scam) # Create Interactive View in window dcam = pangolin.CreateDisplay() dcam.SetBounds(0.0, 1.0, 0.0, 1.0, w/h) dcam.SetHandler(handler) # hack to avoid small Pangolin, no idea why it's *2 dcam.Resize(pangolin.Viewport(0,0,w*2,h*2)) dcam.Activate() poses = [] # pose = np.hstack((np.identity(3), np.zeros((3,1)))) pose = np.identity(4) poses.append(np.linalg.inv(pose)) while not pangolin.ShouldQuit(): gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.0, 0.0, 0.0, 1.0) dcam.Activate(scam) pose[2, 3] = pose[2, 3] - 1 poses.append(np.linalg.inv(pose)) print(poses[-1]) gl.glLineWidth(3) gl.glColor3f(0.0, 1.0, 0.0) pangolin.DrawCameras(poses) # pangolin.DrawCamera(pose) time.sleep(0.2) # pangolin.DrawCameras(np.linalg.inv(poses[-1])) # pangolin.DrawCameras(np.stack(poses, axis=0)) # print(np.stack(poses,axis=2).shape) pangolin.FinishFrame()
def __init__(self): pangolin.CreateWindowAndBind('Main', 640, 480) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(640, 480, 520, 520, 320, 240, 0.2, 200), pangolin.ModelViewLookAt(0, 1, -3, 0, 0, 0, pangolin.AxisY)) self.tree = pangolin.Renderable() self.tree.Add(pangolin.Axis()) handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) self.dcam.SetHandler(handler) self.dcam.SetDrawFunction(self._draw) self.pts_prev = [0, 0, 0]
def main(): pango.CreateWindowAndBind('frustrum render', 640, 480) # Projection and ModelView Matrices scam = pango.OpenGlRenderState( pango.ProjectionMatrix(640, 480, 2000, 2000, 320, 240, 0.1, 5000), pango.ModelViewLookAt(0, -50, -10, 0, 0, 0, 0, -1, 0)) #pango.AxisDirection.AxisY)) handler = pango.Handler3D(scam) # Interactive View in Window disp_cam = pango.CreateDisplay() disp_cam.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0 / 480.0) disp_cam.SetHandler(handler) # create and append pose matrices for cameras pose = np.identity(4) poses = [] for i in range(3): poses.append(np.linalg.inv(pose)) pose[2, 3] -= 1 while not pango.ShouldQuit(): # Clear screen gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) gl.glClearColor(0.15, 0.15, 0.15, 0.0) disp_cam.Activate(scam) # Render Cameras gl.glLineWidth(2) gl.glColor3f(1.0, 0.0, 1.0) pango.DrawCamera(poses[0]) gl.glColor3f(0.2, 1.0, 0.2) pango.DrawCameras(poses[1:-1]) gl.glColor3f(1.0, 1.0, 1.0) pango.DrawCamera(poses[-1]) # End frame update pango.FinishFrame()
def init(self, width, height): """Initialize the 3D display (pangolin) :width: TODO :height: TODO :returns: TODO """ pangolin.CreateWindowAndBind('Map viewer', width, height) gl.glEnable(gl.GL_DEPTH_TEST) # Define Projection and initial ModelView matrix self.scam = pangolin.OpenGlRenderState( pangolin.ProjectionMatrix(width, height, 420, 420, width // 2, height // 2, 0.2, 10000), pangolin.ModelViewLookAt(0, -10, -8, 0, 0, 0, 0, -1, 0)) self.handler = pangolin.Handler3D(self.scam) # Create Interactive View in window self.dcam = pangolin.CreateDisplay() self.dcam.SetBounds(0.0, 1.0, 0.0, 1.0, -width / height) self.dcam.SetHandler(self.handler)