【问题标题】:How to show the Color image feed from kinect using freenect2-python如何使用 freenect2-python 显示来自 kinect 的彩色图像馈送
【发布时间】:2021-01-08 02:17:52
【问题描述】:

我正在使用freenect2-python 从 kinectv2 读取帧。以下是我的代码:

from freenect2 import Device, FrameType
import cv2
import numpy as np

def callback(type_, frame):
    print(f'{type_}, {frame.format}') 
    if type_ is FrameType.Color: # FrameFormat.BGRX
        rgb = frame.to_array().astype(np.uint8)
        cv2.imshow('rgb', rgb[:,:,0:3])

device = Device()
while True:
    device.start(callback)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        device.stop()
        break

色框格式为FrameFormat.BGRX,所以我取前3个通道来显示图像。但它显示一个空白的黑色窗口。

我使用了PIL,但它会为接收到的每一帧打开一个新窗口。有没有办法在PIL的同一窗口中显示框架?

【问题讨论】:

    标签: python-imaging-library kinect imshow opencv-python libfreenect2


    【解决方案1】:

    cv2.imshow 无法显示任何内容,因为它不断更新新框架。我在cv2.imshow 之后添加了cv2.waitkey(100),它起作用了。

    def callback(type_, frame):
        print(f'{type_}, {frame.format}') 
        if type_ is FrameType.Color: # FrameFormat.BGRX
            rgb = frame.to_array().astype(np.uint8)
            cv2.imshow('rgb', rgb[:,:,0:3])
            # added the following line of code
            cv2.imshow(100) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-14
      • 2017-02-21
      • 2015-09-26
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 2015-01-14
      相关资源
      最近更新 更多