static void Main(string[] args)
        {
            var baseConfig = new Configuration();

            baseConfig.nAreaForStrokeMap   = 15;
            baseConfig.minRadiusArea       = 0.03;
            baseConfig.toleranceFactorArea = 1.3;

            var paramVar1 = new DoubleParamVariation("nAreaForStrokeMap", 10, 2, 20);
            var paramVar2 = new DoubleParamVariation("minRadiusArea", 0.01, 0.02, 0.19);
            var paramVar3 = new DoubleParamVariation("toleranceFactorArea", 1.1, 0.1, 2.1);

            var configSet = baseConfig.getParameterVariations(paramVar1, paramVar2, paramVar3);


            Stream          TestFileStream;
            BinaryFormatter serializer = new BinaryFormatter();
            Dictionary <string, GestureTrace[]> circleGestures, squareGestures, ownFormGestures;

            if (File.Exists("Circle_1Finger.gestures"))
            {
                TestFileStream = File.OpenRead("Circle_1Finger.gestures");
                circleGestures = (Dictionary <string, GestureTrace[]>)serializer.Deserialize(TestFileStream);
                TestFileStream.Close();
            }
            else
            {
                circleGestures = getGestureTraces("Circle_1Finger");

                TestFileStream = File.Create("Circle_1Finger.gestures");
                serializer.Serialize(TestFileStream, circleGestures);
                TestFileStream.Close();
            }

            if (File.Exists("Square_1Finger.gestures"))
            {
                TestFileStream = File.OpenRead("Square_1Finger.gestures");
                squareGestures = (Dictionary <string, GestureTrace[]>)serializer.Deserialize(TestFileStream);
                TestFileStream.Close();
            }
            else
            {
                squareGestures = getGestureTraces("Square_1Finger");

                TestFileStream = File.Create("Square_1Finger.gestures");
                serializer.Serialize(TestFileStream, squareGestures);
                TestFileStream.Close();
            }

            if (File.Exists("OwnForm_1Finger.gestures"))
            {
                TestFileStream  = File.OpenRead("OwnForm_1Finger.gestures");
                ownFormGestures = (Dictionary <string, GestureTrace[]>)serializer.Deserialize(TestFileStream);
                TestFileStream.Close();
            }
            else
            {
                ownFormGestures = getGestureTraces("OwnForm_1Finger");

                TestFileStream = File.Create("OwnForm_1Finger.gestures");
                serializer.Serialize(TestFileStream, ownFormGestures);
                TestFileStream.Close();
            }

            var gesturesToTest = ownFormGestures;

            var nSubsets = 4;
            var results  = new Dictionary <Configuration, IEnumerable <CrossValidator.RecognitionResultRow> >(1000);

            foreach (var config in configSet)
            {
                var recSystem = new RecognitionSystem(config);
                var rows      = CrossValidator.validateRecognition(recSystem, gesturesToTest, nSubsets);
                results[config] = rows;
            }

            CrossValidator.saveResultsToFile(@"F:\Dropbox\LfS\Code\GestureRecognitionTests\GestureRecognition_OwnForm.csv", results);

            //do evaluation

            //Console.WriteLine(model.evaluate(squareTraces.First().Value.First()));



            //var crossValidator = new CrossValidator();

            //////saveSymbolTracesToDatabase();
            //var resCircle = crossValidator.validate(circleTraces, "Circle_1Finger", nSubsets);
            //var resSquare = crossValidator.validate(squareTraces, "Square_1Finger", nSubsets);
            //var resOwnForm = crossValidator.validate(ownFormTraces, "OwnForm_1Finger", nSubsets);

            //var resAll = resCircle.Concat(resSquare).Concat(resOwnForm);
            //saveResultsToFile(@"F:\Dropbox\LfS\Code\GestureRecognitionTests\crossValidation_Extrema.csv", resAll);//resAll);


            ////DBtoExcel(@"D:\Dropbox\LfS\Data\Multitouch_Userstudy\Traces.csv");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var baseConfig = new Configuration();

            baseConfig.nAreaForStrokeMap   = 15;
            baseConfig.minRadiusArea       = 0.03;
            baseConfig.toleranceFactorArea = 1.3;

            //var paramVar1 = new ParameterVariation("nAreaForStrokeMap", 10, 2, 20);
            var paramVar2 = new DoubleParamVariation("minRadiusArea", 0.005, 0.025, 0.18);
            var paramVar3 = new DoubleParamVariation("toleranceFactorArea", 1.05, 0.05, 1.5);
            var paramVar4 = new DoubleParamVariation("areaPointDistance", 0.05, 0.05, 0.2);



            var configSet = Configuration.getParameterVariations(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10);

            Stream          TestFileStream;
            BinaryFormatter serializer = new BinaryFormatter();
            Dictionary <string, GestureTrace[]> timGestures;

            if (File.Exists("Tim.gestures"))
            {
                TestFileStream = File.OpenRead("Tim.gestures");
                timGestures    = (Dictionary <string, GestureTrace[]>)serializer.Deserialize(TestFileStream);
                TestFileStream.Close();
            }
            else
            {
                string user = "******";
                //string[] gestures = new string[] { "Triangle_Slow", "Triangle_Normal", "Triangle_Fast", "Circle_Slow", "Circle_Normal", "Circle_Fast", "D_Slow", "D_Normal", "D_Fast", "Circle_FastLeftSlowRight", "Circle_SlowLeftFastRight" };
                //string[] gestures = new string[] { "Triangle_Slow", "Triangle_Fast", "Circle_Slow", "Circle_Fast", "D_Slow", "D_Fast", "Circle_1Stop_Bottom", "Circle_2Stop_LeftRight" };
                string[] gestures = new string[] { "Triangle_Slow", "Triangle_Fast", "Circle_Slow", "Circle_Fast", "D_Slow", "D_Fast" };

                timGestures = gestures.Select(g => new { GestureName = g, Traces = getGestureTraces(user, g) }).ToDictionary(e => e.GestureName, e => e.Traces);

                TestFileStream = File.Create("Tim.gestures");
                serializer.Serialize(TestFileStream, timGestures);
                TestFileStream.Close();
            }

            var gesturesToTest = timGestures;

            var       nSubsets = 5;
            var       results  = new Dictionary <Configuration, IEnumerable <CrossValidator.RecognitionResultRow> >(1000);
            Stopwatch sw       = new Stopwatch();

            sw.Start();
            foreach (var config in configSet)
            {
                var recSystem = new RecognitionSystem(config);
                var rows      = CrossValidator.validateRecognition(recSystem, gesturesToTest, nSubsets);
                results[config] = rows;
            }
            var neededTime = sw.ElapsedMilliseconds;

            Console.WriteLine(neededTime);
            CrossValidator.saveResultsToFile(@"D:\Dropbox\LfS\Code\GestureRecognitionTests\GestureRecognition_TimGestures_2Subsets_Test.csv", results);

            //do evaluation

            //Console.WriteLine(model.evaluate(squareTraces.First().Value.First()));



            //var crossValidator = new CrossValidator();

            //////saveSymbolTracesToDatabase();
            //var resCircle = crossValidator.validate(circleTraces, "Circle_1Finger", nSubsets);
            //var resSquare = crossValidator.validate(squareTraces, "Square_1Finger", nSubsets);
            //var resOwnForm = crossValidator.validate(ownFormTraces, "OwnForm_1Finger", nSubsets);

            //var resAll = resCircle.Concat(resSquare).Concat(resOwnForm);
            //saveResultsToFile(@"F:\Dropbox\LfS\Code\GestureRecognitionTests\crossValidation_Extrema.csv", resAll);//resAll);


            ////DBtoExcel(@"D:\Dropbox\LfS\Data\Multitouch_Userstudy\Traces.csv");
        }