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 paramVar3 = new DoubleParamVariation("toleranceFactorArea", 1.1, 0.1, 2.1);
            var paramVar2 = new DoubleParamVariation("minRadiusArea", 0.01, 0.02, 0.19);

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


            Stream          TestFileStream;
            BinaryFormatter serializer = new BinaryFormatter();
            Dictionary <string, GestureTrace[]> circleGestures, squareGestures, ownFormGestures, 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();
            }

            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 = timGestures;
            Stopwatch sw       = new Stopwatch();
            var       nSubsets = 5;
            var       results  = new Dictionary <Configuration, IEnumerable <CrossValidator.AuthenticationResultRow> >(1000);

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

            Console.WriteLine(neededTime);
            CrossValidator.saveResultsToFile(@"D:\Dropbox\LfS\Code\GestureRecognitionTests\GestureAuthentication_TimGestures_5Subsets.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");
        }
Esempio n. 2
0
    public bool PosTest6()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest6: Call Dispose twice with disposing set to true once and another time set to false");

        try
        {
            TestFileStream tfs = new TestFileStream(c_DEFAULT_FILE_PATH, FileMode.Append);

            tfs.DisposeWrapper(true);
            tfs.DisposeWrapper(false);
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }