def setUp(self):
        self.gesture_db = GestureDatabase()
        self.gesture = self.gesture_db.get_gesture_entry("come_here")
        self.D = self.gesture.dimensionality
        self.gesture.process_signal_accommodation()
        self.coordinates = self.gesture.get_merged_training_data()
        for i in xrange(len(self.coordinates)):
            for j in xrange(len(self.coordinates[i])):
                self.coordinates[i][j] = self.coordinates[i][j] * 100.0

        self.__learning_system = None
        help=
        "models to evaluate. if no specified, all that are evaluated. Otherwise provide comma separated models names ie: -m HMMGestureModel,GMMGestureModel,Time-GMMGestureModel,DTWGestureModel"
    )
    (options, args) = parser.parse_args()

    if options.gesture_entries != None:
        gesture_entries_names = options.gesture_entries.split(",")
    else:
        #default gestures to evaluate
        rospy.loginfo(
            "gestures must be specified using the parameter -g or (--gestures-entries). See help."
        )
        exit()

    rospy.loginfo("gestures to be analyzed: %s", str(gesture_entries_names))
    gesture_db = GestureDatabase()
    #gesture_entries_names=["come_here"]

    print "models to load: %s" % str(options.models_types)
    if options.models_types == None:
        models_names = gesture_db.get_models_names()
    else:
        models_types_name = options.models_types.split(",")
        models_names = []
        for mt in models_types_name:
            models_names = models_names + gesture_db.get_models_names(
                model_type_name=mt)

    print "models found: %s" % str(models_names)

    #cache for avoiding load models
Ejemplo n.º 3
0
def generate_images(gestures_to_paint, time_wrapping=False):
    gesture_db = GestureDatabase()
    images = []
    max_number_demos = 24
    functions = get_plot_functions()
    image_index = 0

    for gesture_entry_name in gestures_to_paint:
        #load gesture
        gesture = gesture_db.get_gesture_entry(gesture_entry_name)
        print "loading gesture: %s" % gesture_entry_name

        try:

            #data preprocessing
            gesture.process_signal_accommodation(
                offset_accomodate=True,
                demo_longitude_accomodate=True,
                regular_sampling_acomodation=True,
                time_wrapping=False)

            for f in functions:
                #create plotting infrastructure
                fig1 = matplotlib.pyplot.figure(image_index)
                fig1.clear()
                leg = []
                #plot
                number_of_demos = min(max_number_demos,
                                      gesture.demonstration_count)
                m = None
                (plot_key_name, leg) = f(gesture, m, fig1, number_of_demos)

                if leg != None:
                    legend(tuple(leg))

                images.append((gesture.name, fig1))
                if m != None:
                    imageurl = REPORT_DIR + "/" + f.__name__ + "/" + gesture_entry_name + "-" + plot_key_name + ".png"
                else:
                    imageurl = REPORT_DIR + "/" + f.__name__ + "/" + gesture_entry_name + ".png"
                fig1.savefig(imageurl)
                image_index += 1
        except:
            continue
        '''models=gesture_db.get_models_by_gesture_name(gesture.name+".time.*k2time_wrapped\.gmm")
        print "loading models: %s"+str(models)
        models= [None]+models
        
        for m in models:
            for f in functions:
                #create plotting infrastructure
                fig1 = matplotlib.pyplot.figure(image_index)
                fig1.clear()
                leg=[]
                #plot
                number_of_demos=min(max_number_demos,gesture.demonstration_count)
                (plot_key_name,leg)=f(gesture,m,fig1,number_of_demos)
                    
                if leg!=None:
                    legend(tuple(leg))
                    
                images.append((gesture.name,fig1))
                imageurl=REPORT_DIR+"/"+f.__name__+"/"+gesture_entry_name+"-"+plot_key_name+".png"
                fig1.savefig(imageurl)
                image_index+=1
        '''

    return images