直接使用PyKinect的Kinect RGB数据,不用pygame,要用OpenCV处理

Kinect RGB data using PyKinect directly, without pygame, to be processed using OpenCV

我正在使用 pygame 和 Kinect 传感器 v1(当然在 python 中)。 有没有什么方法可以直接使用来自传感器的数据来使用opencv进行处理? (没有 pygame)

我尝试使用 frame.image.bits,但它给了我一个一维数组。 有什么方法可以从传感器获取帧作为帧图像,以便我可以使用 opencv 对其进行处理?

from pykinect import nui
import numpy
import cv2

def video_handler_function(frame):

    video = numpy.empty((480,640,4),numpy.uint8)
    frame.image.copy_bits(video.ctypes.data)

    cv2.imshow('KINECT Video Stream', video)


#------------------------------------main------------------------------------
kinect = nui.Runtime()
kinect.video_frame_ready += video_handler_function
kinect.video_stream.open(nui.ImageStreamType.Video, 2,nui.ImageResolution.Resolution640x480,nui.ImageType.Color)

cv2.namedWindow('KINECT Video Stream', cv2.WINDOW_AUTOSIZE)

while True:

    key = cv2.waitKey(1)
    if key == 27: break

kinect.close()
cv2.destroyAllWindows()
#------------------------------------main------------------------------------