def __renderFrame(self): # looping? if self.__head < 0: if self.__loop: self.__head += self.__frameCount else: self.__head = 0 self.__play(0) return elif self.__head > self.__frameCount: if self.__loop: self.__head -= self.__frameCount else: self.__head = self.__frameCount self.__play(0) return idx = int(self.__head) if self.__last == idx: return self.__last = idx frame = _BUFFER[idx] core.add_texture("temp", frame, self.__width, self.__height) core.draw_image("Canvas", "temp", [0, 0], pmax=[self.__width, self.__height])
def refresh(self): core.add_texture( "geomap", self.stored_map, 256 * (2 * self.tile_radius + 1), 256 * (2 * self.tile_radius + 1), ) core.draw_image("canvas", "geomap", [0, 0], self.map_size)
def produce_frame(): global frame global running capture = cv.VideoCapture(0) running=True while capture.isOpened() and running: time.sleep(0.1) ret, frame = capture.read() # gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) img =frame b = np.ones([img.shape[0], img.shape[1], 1]) * 255 img = np.c_[img, b].astype(int) dpg_image2 = img.flatten().tolist() dpg.add_texture("texture id", dpg_image2, img.shape[1], img.shape[0]) dpg.draw_image('drawing', "texture id", [0, 0], [500, 300]) # return frame if cv.waitKey(30) == ord('q'): break
def construct(self): self.adjust_coordinate_to_center_tile() with simple.group(self.name, parent=self.parent): core.add_drawing("canvas", width=self.map_size[0], height=self.map_size[1]) core.add_texture( "geomap", self.stored_map, 256 * self.tile_radius, 256 * self.tile_radius, ) if self.cached == False: # Only use if necessary so that the OSM tile servers are not overloaded. self.async_update_by_coordinate(self.latitude, self.longitude, self.zoom) else: self.refresh()
def texture_callback(): frame = camera.get_frame() frame = cv2.cvtColor(frame, cv2.COLOR_RGB2RGBA) add_texture("texture", frame, 640, 480)
with group("Left Panel", width=200): add_button("Start Video", callback=video_callback) add_same_line() add_button("End Video", callback=video_callback) add_checkbox("Recording", default_value=False, source="is_recording") add_same_line(spacing=20) add_checkbox("Goggle View", default_value=False, source="display_goggle_view") for name, (low, high, step, default) in parameters.items(): add_slider_int(name, default_value=default, min_value=low, max_value=high, source=name) add_same_line() image = np.zeros((640, 480, 3), dtype=np.uint8) image = cv2.cvtColor(image, cv2.COLOR_RGB2RGBA) add_texture("texture", image, 640, 480) add_image("canvas", "texture") add_slider_float("FPS", max_value=60, enabled=False, no_input=True, source="realtime_fps") add_data("video_on", False) set_render_callback(update_canvas) start_dearpygui(primary_window="Main Window")