def gl_display(self): """ This is where we can draw to any gl surface by default this is the main window, below we change that """ # active our window active_window = glfwGetCurrentContext() glfwMakeContextCurrent(self.window) # start drawing things: gl_utils.clear_gl_screen() # set coordinate system to be between 0 and 1 of the extents of the window gl_utils.make_coord_system_norm_based() # draw the image draw_gl_texture(self.img) # make coordinte system identical to the img pixel coordinate system gl_utils.make_coord_system_pixel_based(self.img.shape) # draw some points on top of the image # notice how these show up in our window but not in the main window draw_points([(200, 400), (600, 400)], color=RGBA(0., 4., .8, .8), size=self.my_var) draw_polyline([(200, 400), (600, 400)], color=RGBA(0., 4., .8, .8), thickness=3) # since this is our own window we need to swap buffers in the plugin glfwSwapBuffers(self.window) # and finally reactive the main window glfwMakeContextCurrent(active_window)
def _draw_frame(window, path, frames, index: int, show_help: bool): frames_data = [frame.load(path) for frame in frames[index]] for frame, frame_meta in zip(frames_data, frames[index]): PreviewWindow._draw_text( frame, "Preview {}/{} (eye{})".format(index + 1, len(frames), frame_meta.eye_id), (15, frame.shape[0] - 30), ) #PreviewWindow._draw_text( # frame, # "Confidence: {}".format(frame_meta.confidence), # (15, frame.shape[0] - 30), #) frame = frames_data[0] if len(frames_data) == 1 else np.hstack( frames_data) # Present usage hints at first load if show_help: PreviewWindow._draw_text( frame, "Usage: Use the arrow keys for navigating between frames.", (15, 40), ) with PreviewWindow.WindowContextManager(window): clear_gl_screen() make_coord_system_norm_based() draw_gl_texture(frame, interpolation=False) glfw.glfwSwapBuffers(window)
def gl_display(self): if self._recent_blink and self.visualize: if self._recent_blink['type'] == 'onset': cygl_utils.push_ortho(1, 1) cygl_utils.draw_gl_texture( np.zeros((1, 1, 3), dtype=np.uint8), alpha=self._recent_blink['confidence'] * 0.5) cygl_utils.pop_ortho()
def gl_display_in_window(self, img): active_window = glfwGetCurrentContext() glfwMakeContextCurrent(self._window) clear_gl_screen() # gl stuff that will show on your plugin window goes here make_coord_system_norm_based() draw_gl_texture(img, interpolation=False) glfwSwapBuffers(self._window) glfwMakeContextCurrent(active_window)
def gl_display_in_window(self,img): active_window = glfwGetCurrentContext() glfwMakeContextCurrent(self._window) clear_gl_screen() # gl stuff that will show on your plugin window goes here make_coord_system_norm_based() draw_gl_texture(img,interpolation=False) glfwSwapBuffers(self._window) glfwMakeContextCurrent(active_window)
def gl_display(self): if self._recent_blink and self.visualize: if self._recent_blink["type"] == "onset": cygl_utils.push_ortho(1, 1) cygl_utils.draw_gl_texture( np.zeros((1, 1, 3), dtype=np.uint8), alpha=self._recent_blink["confidence"] * 0.5, ) cygl_utils.pop_ortho()
def gl_display_in_t265_window(self): """ Show new frame in window. """ active_window = glfwGetCurrentContext() glfwMakeContextCurrent(self.t265_window) clear_gl_screen() if self.last_video_frame is not None: make_coord_system_norm_based() draw_gl_texture(self.last_video_frame) glfwSwapBuffers(self.t265_window) glfwMakeContextCurrent(active_window)
def gl_display(self): for grid_points in self.img_points: calib_bounds = cv2.convexHull(grid_points)[:,0] #we dont need that extra encapsulation that opencv likes so much draw_polyline(calib_bounds,1,RGBA(0.,0.,1.,.5),line_type=gl.GL_LINE_LOOP) if self._window: self.gl_display_in_window() if self.show_undistortion: gl.glPushMatrix() make_coord_system_norm_based() draw_gl_texture(self.undist_img) gl.glPopMatrix()
def draw_markers(self): xs, ys = glfwGetFramebufferSize(self._window) aspect = xs / float(ys) marker_ids = [0,1,2,4,5] #3 missing because of stupidity in the simulator positions = [[0.5, 0.8],[1 - 0.15/aspect, 0.8], [0.15/aspect, 0.1], [1 - 0.15/aspect, 0.1], [0.15/aspect, 0.8]] s = int(ys * 0.1) for mid, pos in zip(marker_ids, positions): canvas = self.screen_markers[mid] x = (pos[0]*xs - 0.5*s) y = (pos[1]*ys - 0.5*s) adjust_gl_view(s,s, int(x), int(y) ) make_coord_system_norm_based() draw_gl_texture(canvas) make_coord_system_pixel_based on_resize(self._window,*glfwGetFramebufferSize(self._window))
def gl_display(self): """ This is where we can draw to any gl surface by default this is the main window, below we change that """ # active our window #active_window = glfwGetCurrentContext() #glfwMakeContextCurrent(self.window) # start drawing things: gl_utils.clear_gl_screen() # set coordinate system to be between 0 and 1 of the extents of the window gl_utils.make_coord_system_norm_based() # draw the image try: draw_gl_texture(self.img) gl_utils.make_coord_system_pixel_based(self.img.shape) except AttributeError: pass
def gl_display(self): # blink? if int(self.blink_counter / 10) % 2 == 1: if self.currently_recording.is_set(): draw_points_norm([(0.01, 0.1)], size=35, color=RGBA(0.1, 1.0, 0.1, 0.8)) if self.currently_saving.is_set(): draw_points_norm([(0.01, 0.01)], size=35, color=RGBA(1.0, 0.1, 0.1, 0.8)) self.blink_counter += 1 if (self.preview_ximea): if (self.currently_recording.is_set()): #if we are currently saving, don't grab images im = np.ones((*self.imshape, 3)).astype(np.uint8) alp = 0 elif (not self.camera_open): logger.info(f'Unable to Open Camera!') self.preview_ximea = False im = np.zeros((*self.imshape, 3)).astype(np.uint8) alp = 0.5 else: im = ximea_utils.decode_ximea_frame(self.camera, self.image_handle, self.imshape, logger) alp = 1 #cv2.imshow('image',im) #cv2.imwrite('/home/vasha/img.png', im) gl_utils.make_coord_system_norm_based() draw_gl_texture(im, interpolation=True, alpha=alp) if (self.record_ximea): if not self.camera_open: logger.info('Camera Not Open!') self.record_ximea = False