Example #1
0
        /**
         * After the command is complete, update the matrices
         * with detected gestures.
         */
        public void update_confusion_matrices(ConfusionMatrices cm)
        {
            bool found = false;

            for (int ii = 0;
                 ii < detected_ids.Count;
                 ii++)
            {
                int detected_id = detected_ids[ii];

                if (found && expected_id == detected_id)
                {
                    // treat as false positive
                    // because we've already detected
                    // the gesture once
                    cm.AddResult(
                        expected_id,
                        -2);
                    continue;
                }

                cm.AddResult(
                    expected_id,
                    detected_id);

                // mark that we've found this gesture
                found = found || (detected_id == expected_id);
            }

            // false negative
            if (!found)
            {
                cm.AddResult(
                    expected_id,
                    -1);
            }
        }
Example #2
0
        /**
         * A simple user independent test.
         */
        public static void user_indepedent_test(DeviceType device)
        {
            // First, load all training data for one device type.
            string path = "";

            if (device == DeviceType.KINECT)
            {
                path = Global.GetRootDirectory() + "datasets/jk2017/kinect/training/";
            }
            else if (device == DeviceType.LEAP_MOTION)
            {
                path = Global.GetRootDirectory() + "datasets/jk2017/leap_motion/training/";
            }


            Dataset ds = Dataset.LoadDataset(path);

            int subject_cnt      = ds.Subjects.Count;
            int sample_cnt       = ds.Samples.Count;
            ConfusionMatrices cm = new ConfusionMatrices(ds);

            // iterate through all subjects
            for (int subject_id = 0; subject_id < subject_cnt; subject_id++)
            {
                ConfusionMatrices cm_individual = new ConfusionMatrices(ds);

                Console.WriteLine("Participant: " + subject_id);

                // train a recognizer with the selected subject
                JackknifeBlades blades = new JackknifeBlades();

                blades.SetIPDefaults();

                Jackknife jk = new Jackknife(blades);

                for (int sample_id = 0; sample_id < sample_cnt; sample_id++)
                {
                    Sample sample = ds.Samples[sample_id];

                    if (sample.SubjectId != subject_id)
                    {
                        continue;
                    }

                    jk.AddTemplate(ds.Samples[sample_id]);
                }

                // only train the recognize if you need

                // test the recognizer with all other samples
                for (int sample_id = 0; sample_id < sample_cnt; sample_id++)
                {
                    Sample sample = ds.Samples[sample_id];

                    if (sample.SubjectId == subject_id)
                    {
                        continue;
                    }

                    int gid = jk.Classify(sample);

                    cm_individual.AddResult(
                        sample.GestureId,
                        gid);
                }

                cm.AddResult(cm_individual);

                ResultT resultss = cm_individual.Results();
                resultss.Print();
            }

            Console.WriteLine("Aggregate Results: ");
            ResultT results = cm.Results();

            results.Print();
        }