+
+ screen = pygame.display.get_surface()
+ self.xratio = float(screen.get_size()[0]) / SCREEN_SIZE[0]
+ self.yratio = float(screen.get_size()[1]) / SCREEN_SIZE[1]
+ self.handCenteredPosition = None
+ self.pygameScreenWidth, self.pygameScreenHeight = screen.get_size()
+
+ def getProjPos(self, realPos) :
+ return self.depthGene.to_projective([realPos])[0]
+
+ def setMousePosition(self, realPos) :
+ if self.mouseMode == MOUSE_SCREEN_COORDINATES :
+ x, y, z = self.getProjPos(realPos)
+ # mirror
+ x = SCREEN_SIZE[0] - x
+ # scale
+ x, y = x * self.xratio, y * self.yratio
+ elif self.mouseMode == MOUSE_REAL_COORDINATES :
+ x, y = realPos[:2]
+ x, y = x - self.handCenteredPosition[0], y - self.handCenteredPosition[1]
+ x = -x # miroir
+ x, y = x + DEFAULT_HAND_DISTANCE_RANGE, DEFAULT_HAND_DISTANCE_RANGE - y
+ x, y = map(lambda i : numpy.clip(i, 0, DEFAULT_HAND_DISTANCE_RANGE * 2), [x, y])
+ x = x * (self.pygameScreenWidth / (2. * DEFAULT_HAND_DISTANCE_RANGE))
+ y = y * (self.pygameScreenHeight / (2. * DEFAULT_HAND_DISTANCE_RANGE))
+
+ pygame.mouse.set_pos(int(x), int(y))
+
+ def handCreateCB(self, src, id, pos, time):
+ print 'Create ', id, pos
+
+ def handUpdateCB(self, src, id, pos, time):
+ self.setMousePosition(pos)
+
+ def handDestroyCB(self, src, id, time):
+ print 'Destroy ', id
+
+ def gestureRecognizedCB(self, src, gesture, id, end_point) :
+ print 'gestureDetected', src, gesture, id, end_point
+
+ def gestureProgressCB(self, src, gesture, point, progress) :
+ print 'gestureProgress', src, gesture, point, progress
+ self.handsGene.start_generating()
+ self.handsGene.start_tracking(point)
+ self.handCenteredPosition = point
+
+ def newUserCB(self, *args, **kw) :
+ print 'newUserCB', args, kw
+
+ def lostUserCB(self, *args, **kw) :
+ print 'lostUserCB', args, kw
+