예제 #1
0
    def classifyGesture(self):
        minError = 2**31 - 1  # a large value
        minErrorIndex = -1
        self.humanGesture = Gesture(self.gesturePoints, "Human Gesture")
        likelihoodScores = [0] * len(self.gestures)
        assessments = [{}] * len(self.gestures)
        for i in xrange(len(self.gestures)):
            assessments[i] = Gesture.compareGestures(self.gestures[i],
                                                     self.humanGesture)
        errorList = [assessments[i][Gesture.totalError] \
                        for i in xrange(len(assessments))]
        index = errorList.index(min(errorList))
        # Basic elimination to figure out if result is valid

        # show appropriate images in windows

        templateGestureRatio = max((self.gestures[index].distance /\
                                    self.humanGesture.distance),
                                    (self.humanGesture.distance /\
                                        self.gestures[index].distance))
        distanceDiffRatio = assessments[index][Gesture.totalDistance] /\
                                min(self.gestures[index].distance,
                                    self.humanGesture.distance)
        if templateGestureRatio < 1.25 and distanceDiffRatio < 2:
            return index
예제 #2
0
 def classifyGesture(self):
     minError = 2**31 - 1  # a large value
     minErrorIndex = -1
     self.humanGesture = Gesture(self.gesturePoints, "Human Gesture")
     likelihoodScores = [0] * len(self.gestures)
     assessments = [{}] * len(self.gestures)
     for i in xrange(len(self.gestures)):
         # print "Calling:", self.gestures[i].name, self.humanGesture.name
         assessments[i] = Gesture.compareGestures(self.gestures[i],
                                                  self.humanGesture)
         # print self.gestures[i].name
         # print assessments[i]
     errorList = [
         assessments[i][Gesture.totalError]
         for i in xrange(len(assessments))
     ]
     index = errorList.index(min(errorList))
     # Basic elimination to figure out if result is valid
     templateGestureRatio = max(
         (self.gestures[index].distance / self.humanGesture.distance),
         (self.humanGesture.distance / self.gestures[index].distance))
     distanceDiffRatio = assessments[index][Gesture.totalDistance] / min(
         self.gestures[index].distance, self.humanGesture.distance)
     if templateGestureRatio < 1.25 and distanceDiffRatio < 2:
         self.gestures[index].action()
예제 #3
0
 def classifyGesture(self):
     minError = 2**31 - 1 # a large value
     minErrorIndex = -1
     self.humanGesture = Gesture(self.gesturePoints, "Human Gesture")
     likelihoodScores = [0] * len(self.gestures)
     assessments = [{}] * len(self.gestures)
     for i in xrange(len(self.gestures)):
         assessments[i] = Gesture.compareGestures(self.gestures[i],
                                                     self.humanGesture)
     errorList = [assessments[i][Gesture.totalError] \
                     for i in xrange(len(assessments))]
     index = errorList.index(min(errorList))
     # Basic elimination to figure out if result is valid
     templateGestureRatio = max((self.gestures[index].distance /\
                                 self.humanGesture.distance), 
                                 (self.humanGesture.distance /\
                                     self.gestures[index].distance))
     distanceDiffRatio = assessments[index][Gesture.totalDistance] /\
                             min(self.gestures[index].distance,
                                 self.humanGesture.distance)
     if templateGestureRatio < 1.25 and distanceDiffRatio < 2:
         return index