我写了一个程序,在pygame屏幕上显示kinect视频频道。在
import thread
import pygame
import easygui
from pykinect import nui
DEPTH_WINSIZE = (640, 480)
screen_lock = thread.allocate()
screen = None
tmp_s = pygame.Surface(DEPTH_WINSIZE, 0, 16)
s=None
def video_frame_ready(frame):
with screen_lock:
frame.image.copy_bits(tmp_s._pixels_address)
arr2d = (pygame.surfarray.pixels2d(tmp_s) >> 7) & 255
pygame.surfarray.blit_array(screen, arr2d)
pygame.display.update()
def main():
"""Initialize and run the game"""
pygame.init()
global s
s=0
global arr
arr = []
# Initialize PyGame
global screen
screen = pygame.display.set_mode(DEPTH_WINSIZE, 0, 8)
screen.set_palette(tuple([(i, i, i) for i in range (256)]))
pygame.display.set_caption("PyKinect Depth Map Example")
angle = 0
with nui.Runtime() as kinect:
kinect.video_frame_ready += video_frame_ready
kinect.video_stream.open(nui.ImageStreamType.Video, 2, nui.ImageResolution.Resolution640x480, nui.ImageType.Color)
# Main game loop
while (True):
event = pygame.event.wait()
if (event == pygame.QUIT):
break
if (__name__ == "__main__"):
main()
在frame.image.copy_位(tmp_s.\u pixels_address)行,它给我一个错误:
^{pr2}$有办法解决这个问题吗? 任何帮助都是非常感谢的。在
试试这个:
相关问题 更多 >
编程相关推荐