1 # -*- coding: utf-8 -*-
3 Affichage vidéo (et autres) de la kinect pour expérimentations / debug.
14 SCREEN_SIZE
= 640, 480
15 SCREEN_TITLE
= "Kinect debug"
21 self
.context
= Context()
23 self
.imgGene
= ImageGenerator()
24 self
.imgGene
.create(self
.context
)
25 self
.imgGene
.set_resolution_preset(RES_VGA
)
26 self
.imgGene
.fps
= FPS
27 self
.context
.start_generating_all()
30 rgb_frame
= numpy
.fromstring(self
.imgGene
.get_raw_image_map_bgr(), dtype
=numpy
.uint8
).reshape(480, 640, 3)
31 image
= cv
.fromarray(rgb_frame
)
32 cv
.CvtColor(cv
.fromarray(rgb_frame
), image
, cv
.CV_BGR2RGB
)
33 pyimage
= pygame
.image
.frombuffer(image
.tostring(), cv
.GetSize(image
), 'RGB')
38 return self
.context
.wait_one_update_all(self
.imgGene
)
41 class RGBSprite(pygame
.sprite
.DirtySprite
, RGB
) :
43 def __init__(self
, alpha
=255) :
44 pygame
.sprite
.DirtySprite
.__init
__(self
)
45 self
.dirty
= 2 # toujours dirty !
48 self
.image
= pygame
.Surface((640, 480))
49 self
._regular
= pygame
.Surface((640, 480))
50 self
.image
.set_alpha(alpha
)
51 self
.rect
= pygame
.Rect((0, 0), (0, 0))
56 self
._regular
.blit(img
, (0, 0))
57 self
.image
.blit(pygame
.transform
.flip(self
._regular
, True, False), (0, 0))
62 screen
= pygame
.display
.set_mode(SCREEN_SIZE
)
63 pygame
.display
.set_caption(SCREEN_TITLE
)
67 sur
= pygame
.Surface((640, 480))
68 sur
.fill((255, 255, 255))
71 for event
in pygame
.event
.get():
76 rgbImg
= rgb
.capture()
77 sur
.blit(rgbImg
, (0, 0))
78 screen
.blit(pygame
.transform
.flip(sur
, True, False), (0, 0))
82 if __name__
== "__main__" :