【问题标题】:How to draw a video frame from PyRealSense2 on a PyGame canvas?如何在 PyGame 画布上从 PyRealSense2 绘制视频帧?
【发布时间】:2020-11-24 14:24:43
【问题描述】:

在初始化 PyGame 之后

flags = pygame.FULLSCREEN | pygame.NOFRAME | pygame.DOUBLEBUF | pygame.HWSURFACE
width = 0
height = 0  # fullscreeen

screen = pygame.display.set_mode( ( width, height ), flags )

我从 RealSense 摄像头获取颜色帧

frames = pipeline.wait_for_frames()
colorFrame = frames.get_color_frame()

但是如何在屏幕上绘制这个框架呢?

【问题讨论】:

    标签: python pygame realsense


    【解决方案1】:
    # create a new Surface from the frame's data
    image = pygame.image.frombuffer(colorFrame.data, ( colorFrame.width, colorFrame.height ), 'RGB')
    
    # copy data on screen at position (0, 0)
    screen.blit(image, ( 0, 0 ))
    

    【讨论】:

      猜你喜欢
      • 2015-01-20
      • 2016-02-23
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 2016-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多