30 lines
767 B
Python
30 lines
767 B
Python
import pygame
|
|
from pykinect import nui
|
|
|
|
# Inicialize o pygame
|
|
pygame.init()
|
|
|
|
# Crie uma janela
|
|
screen = pygame.display.set_mode((640, 480), pygame.HWSURFACE | pygame.DOUBLEBUF, 32)
|
|
|
|
# Inicialize o Kinect
|
|
kinect = nui.Runtime()
|
|
|
|
# Loop principal
|
|
while True:
|
|
# Verifique se há eventos de saída
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
kinect.close()
|
|
pygame.quit()
|
|
quit()
|
|
|
|
# Obtenha uma imagem da câmera RGB
|
|
video = kinect.video_stream.get_next_frame()
|
|
if video:
|
|
frame_surface = pygame.image.frombuffer(video.image.bits, (video.image.width, video.image.height), "RGB").convert()
|
|
screen.blit(frame_surface, (0, 0))
|
|
|
|
# Atualize a tela
|
|
pygame.display.update()
|