static void Main(string[] args)
        {
            string lFilePath = ConfigurationManager.AppSettings["outputFileName"] + DateTime.Now.Ticks.ToString() + ".csv";

            StreamWriter     file1      = new StreamWriter(lFilePath, true);
            DTWConfiguration lDTWConfig = new DTWConfiguration()
                                          .UseXY()
                                          .UseX1Y1()
                                          .UseX2Y2()
                                          .UseForce()
                                          .UseForce1();

            Console.Write("Path to directory: ");
            string lPath = Console.ReadLine();

            string[] lSubdirectoryEntries = Directory.GetDirectories(lPath);


            file1.WriteLine("EER_a - XYX'Y'X''Y'' - T5");
            lDTWConfig = new DTWConfiguration()
                         .UseXY()
                         .UseX1Y1()
                         .UseX2Y2();

            foreach (var directory in lSubdirectoryEntries)
            {
                Console.WriteLine("Processing " + directory + " directory");
                SignatureCompareFunctions.CompareMCYT(directory, 5, lDTWConfig, ref file1);
            }

            file1.Close();
        }
        public static double DTWDistance <T>(T aSig1, T aSig2, DTWConfiguration aConfiguration) where T : List <Point>
        {
            double[,] lDTW = new double[aSig1.Count, aSig2.Count];

            for (int i = 1; i < aSig1.Count; ++i)
            {
                lDTW[i, 0] = int.MaxValue;
            }

            for (int i = 1; i < aSig2.Count; ++i)
            {
                lDTW[0, i] = int.MaxValue;
            }

            lDTW[0, 0] = 0;

            for (int i = 1; i < aSig1.Count; ++i)
            {
                for (int j = 1; j < aSig2.Count; ++j)
                {
                    double lCost = DistanceCalculator.CalculateDistance(aSig1.ElementAt(i), aSig2.ElementAt(j), aConfiguration.GetConfiguration());
                    lDTW[i, j] = lCost + DistanceCalculator.Min(lDTW[i - 1, j], lDTW[i, j - 1], lDTW[i - 1, j - 1]);
                }
            }

            return(lDTW[aSig1.Count - 1, aSig2.Count - 1] / (aSig1.Count + aSig2.Count));
        }
예제 #3
0
        public bool CheckSignature([FromBody] SignatureDTO aSig)
        {
            SignatureData lSignatureData = SignatureUtils.SignatureUtils.GetSignatureFromBase64String(aSig.Signature, aSig.Email);

            Signature lSigWithCharacteristics = SignatureUtils.SignatureUtils.CalculateCharacteristics(lSignatureData.Signature);

            lSigWithCharacteristics = SignatureUtils.SignatureUtils.StandardizeSignature(lSigWithCharacteristics);

            var lDirectory = "d:\\Signatures\\" + lSignatureData.Email + "\\";

            //Get all signatures from folder. True flag indicates, that all characteristics we are working with are stored in the file, these will be loaded too
            List <Signature> lSignatures = SignatureFileUtils.GetAllSignaturesFromFolder(lDirectory, true);

            DTWConfiguration lDTWConfig = new DTWConfiguration()
                                          .UseXY()
                                          .UseX1Y1()
                                          .UseX2Y2()
                                          .UseForce()
                                          .UseForce1()
                                          .UsePathVelocity();

            //Check for NaN values at Force and Force1 characrteristics.
            SignatureUtils.SignatureUtils.CheckForNaN(lSigWithCharacteristics, ref lDTWConfig);

            return(SignatureQualityEvaluation.Authenticate(lDirectory, lSigWithCharacteristics, lDTWConfig, 0.05));
        }
        public static void CompareMCYT(string aFolder, int aNrOfTrainingSamples, DTWConfiguration aDTWConfig, ref StreamWriter aSWriter)
        {
            List <Signature> lSignatures = SignatureFileUtils.GetAllSignaturesFromFolder(aFolder);

            List <Signature> lTemplate           = lSignatures.Skip(25).Take(aNrOfTrainingSamples).ToList();
            List <Signature> lOriginalSignatures = lSignatures.Skip(25 + aNrOfTrainingSamples).Take(25 - aNrOfTrainingSamples).ToList();
            List <Signature> lImpostorSignatures = lSignatures.Take(15).ToList();

            for (int i = 0; i < lTemplate.Count; ++i)
            {
                var lElement    = lTemplate.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lTemplate.RemoveAt(i);
                lTemplate.Insert(i, lNewElement);
            }

            for (int i = 0; i < lOriginalSignatures.Count; ++i)
            {
                var lElement    = lOriginalSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lOriginalSignatures.RemoveAt(i);
                lOriginalSignatures.Insert(i, lNewElement);
            }

            for (int i = 0; i < lImpostorSignatures.Count; ++i)
            {
                var lElement    = lImpostorSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lImpostorSignatures.RemoveAt(i);
                lImpostorSignatures.Insert(i, lNewElement);
            }

            List <double> lOriginalScores = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lOriginalSignatures, aDTWConfig);
            List <double> lImpostorScores = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lImpostorSignatures, aDTWConfig);

            ErrorCalculation lError = ErrorCalculationFactory.GetDScoreErrorCalculator();

            lError.CalculateErrors(lOriginalScores, lImpostorScores, 100);

            //var lFARList = lError.GetFARList();
            //var lFRRList = lError.GetFRRList();
            //var lTresholdList = lError.GetThresholdList();

            //for(int i = 0; i < lFARList.Count; ++i)
            //{
            //    aSWriter.WriteLine(lFARList.ElementAt(i) + "," + lFRRList.ElementAt(i) + ", " + lTresholdList.ElementAt(i));
            //}

            aSWriter.WriteLine(lError.GetERR());
        }
예제 #5
0
        public int SaveSignature([FromBody] SignatureDTO aSig)
        {
            //Get signature from the Base64Encoded string
            SignatureData lSignatureData = SignatureUtils.SignatureUtils.GetSignatureFromBase64String(aSig.Signature, aSig.Email);

            var lDirectory = "d:\\Signatures\\" + lSignatureData.Email + "\\";

            if (!System.IO.Directory.Exists(lDirectory))
            {
                System.IO.Directory.CreateDirectory(lDirectory);
            }

            var fileName          = lDirectory + DateTime.Now.Ticks.ToString() + ".csv";
            var lFeaturesFileName = lDirectory + "\\SignatureFeatures\\" + "SignatureFeatures.csv";

            //Calculate characteristics of the received signature and standardize it
            Signature lSigWithCharacteristics = SignatureUtils.SignatureUtils.CalculateCharacteristics(lSignatureData.Signature);

            lSigWithCharacteristics = SignatureUtils.SignatureUtils.StandardizeSignature(lSigWithCharacteristics);

            //Create DTW configuration for the quality evaluation
            DTWConfiguration lDTWConfig = new DTWConfiguration()
                                          .UseXY()
                                          .UseX1Y1();

            //Check the quality of the signature. If it is a poor quality signature, request it once again
            bool lResult = SignatureQualityEvaluation.CheckQuality(lDirectory, lSigWithCharacteristics, lDTWConfig);

            if (lResult)
            {
                //Save function based data to csv file
                SignatureFileUtils.SaveSignatureWithCharacteristicsToFile(lSigWithCharacteristics, fileName);

                try
                {
                    //Save feature based data to csv file
                    SignatureFeatures lFEatures = FeatureCalculator.CalculateFeatures(lSigWithCharacteristics);

                    if (!System.IO.Directory.Exists(lDirectory + "\\SignatureFeatures\\"))
                    {
                        System.IO.Directory.CreateDirectory(lDirectory + "\\SignatureFeatures\\");
                    }

                    SignatureFileUtils.SaveFeatureSetToFile(lFEatures, lFeaturesFileName);
                }
                catch (Exception ex)
                {
                    //If an error occurs, do nothing
                    //An error can occur in case of the pressure related features, beacause some devices don't return the pressure value
                }

                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #6
0
        /// <summary>
        /// Force can be NaN in case of some device and browser combinations, becase it is not implemented in the Touch API.
        /// If there is a NaN value, and Force is present inthe DTW configuration, remove is.
        /// </summary>
        /// <param name="aSig"></param>
        /// <param name="aDTWConfig"></param>
        public static void CheckForNaN(Signature aSig, ref DTWConfiguration aDTWConfig)
        {
            Dictionary <string, bool> lConfig = aDTWConfig.GetConfiguration();

            if ((Double.IsNaN(aSig[3].Force) || Double.IsInfinity(aSig[3].Force)) && lConfig["UseForce"] == true)
            {
                lConfig["UseForce"]  = false;
                lConfig["UseForce1"] = false;
                aDTWConfig.SetConfiguration(lConfig);
            }
        }
        public static void Compare(string aFolder, DTWConfiguration aDTWConfig, ref StreamWriter aSWriter)
        {
            List <Signature> lSignatures = SignatureFileUtils.GetAllSignaturesFromFolder(aFolder);

            List <Signature> lTemplate           = lSignatures.Take(5).ToList();
            List <Signature> lOriginalSignatures = lSignatures.Skip(5).Take(13).ToList();
            List <Signature> lImpostorSignatures = lSignatures.Skip(18).Take(9).ToList();

            for (int i = 0; i < lTemplate.Count; ++i)
            {
                var lElement    = lTemplate.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lTemplate.RemoveAt(i);
                lTemplate.Insert(i, lNewElement);
            }

            for (int i = 0; i < lOriginalSignatures.Count; ++i)
            {
                var lElement    = lOriginalSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lOriginalSignatures.RemoveAt(i);
                lOriginalSignatures.Insert(i, lNewElement);
            }

            for (int i = 0; i < lImpostorSignatures.Count; ++i)
            {
                var lElement    = lImpostorSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lImpostorSignatures.RemoveAt(i);
                lImpostorSignatures.Insert(i, lNewElement);
            }

            List <double> lOriginalScores = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lOriginalSignatures, aDTWConfig);
            List <double> lImpostorScores = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lImpostorSignatures, aDTWConfig);

            ErrorCalculation lError = ErrorCalculationFactory.GetDScoreErrorCalculator();

            lError.CalculateErrors(lOriginalScores, lImpostorScores, 100);
            aSWriter.WriteLine(lError.GetERR());
        }
        /// <summary>
        /// Checks the quality of the signature
        /// Can be used at taking samples, ot at validating a signature
        /// </summary>
        /// <param name="aDirectory"></param>
        /// <param name="aSignature"></param>
        /// <returns></returns>
        public static bool CheckQuality(string aDirectory, Signature aSignature, DTWConfiguration aDTWConfig, double aTolerance = 0.05)
        {
            int lNumberOfRegisteredSamples = SignatureFileUtils.GetNumberOfSignaturesFromFolder(aDirectory);

            if (lNumberOfRegisteredSamples > 1)
            {
                List <Signature> lSignaturesOfUser = SignatureFileUtils.GetAllSignaturesFromFolder(aDirectory, true);
                List <double>    lListOfScores     = new List <double>();


                //Take the first element from the registered samples
                Signature     lSignatureToCompare        = lSignaturesOfUser.ElementAt(0);
                List <double> lListOfScoresRegisteredSig = new List <double>();
                //Compare the first element of the registered signature to the rest of the template and save the scores
                for (int i = 1; i < lSignaturesOfUser.Count; i++)
                {
                    var lSig = lSignaturesOfUser.ElementAt(i);
                    lListOfScoresRegisteredSig.Add(ConfigurableDTW.DTWDistance(lSignatureToCompare, lSig, aDTWConfig));
                }

                //Compare the aSignature sample to the template and save the scores
                foreach (Signature lSig in lSignaturesOfUser)
                {
                    lListOfScores.Add(ConfigurableDTW.DTWDistance(aSignature, lSig, aDTWConfig));
                }

                //Compare the average of the two score lists, accept of reject the signature
                if (lListOfScores.Average() > lListOfScoresRegisteredSig.Average() + aTolerance)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
        public static bool Authenticate(string aDirectory, Signature aSignature, DTWConfiguration aDTWConfig, double aTolerance = 0.05)
        {
            List <Signature> lSignaturesOfUser = SignatureFileUtils.GetAllSignaturesFromFolder(aDirectory, true);
            List <double>    lListOfScores     = new List <double>();

            //Check for NAN in the signature sample
            //If an attribute is NAN, but is checked for usage by the DTWConfig, uncheck it
            SignatureUtils.CheckForNaN(lSignaturesOfUser.ElementAt(0), ref aDTWConfig);

            //Take the first element from the registered samples
            Signature     lSignatureToCompare        = lSignaturesOfUser.ElementAt(0);
            List <double> lListOfScoresRegisteredSig = new List <double>();

            //Compare the first element of the registered signature to the rest of the template and save the scores
            for (int i = 1; i < lSignaturesOfUser.Count; i++)
            {
                var lSig = lSignaturesOfUser.ElementAt(i);
                lListOfScoresRegisteredSig.Add(ConfigurableDTW.DTWDistance(lSignatureToCompare, lSig, aDTWConfig));
            }

            //Compare the aSignature sample to the template and save the scores
            foreach (Signature lSig in lSignaturesOfUser)
            {
                lListOfScores.Add(ConfigurableDTW.DTWDistance(aSignature, lSig, aDTWConfig));
            }

            //Compare the average of the two score lists, accept of reject the signature
            if (lListOfScores.Average() > lListOfScoresRegisteredSig.Average() + aTolerance)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #10
0
        /// <summary>
        /// Compares one signature to all signatures of a template
        /// </summary>
        /// <param name="aTemplate"></param>
        /// <param name="aSignature"></param>
        /// <param name="aDTWConfig"></param>
        /// <returns></returns>
        public static double CompareSignatureDTW(List <Signature> aTemplate, Signature aSignature, DTWConfiguration aDTWConfig)
        {
            int    lCounter = 0;
            double lScore   = 0;

            foreach (Signature refSig in aTemplate)
            {
                lScore += ConfigurableDTW.DTWDistance(refSig, aSignature, aDTWConfig);
                ++lCounter;
            }
            lScore /= lCounter;

            return(lScore);
        }
예제 #11
0
        /// <summary>
        /// Compares each element of the aSignatures parameter to each element of aTemplate.
        /// One signature gets compared to all elements of the template, then an average will be calcutated
        /// </summary>
        /// <param name="aTemplate"></param>
        /// <param name="aSignatures"></param>
        /// <param name="aDTWConfig"></param>
        public static List <double> CompareSignaturesDTW(List <Signature> aTemplate, List <Signature> aSignatures, DTWConfiguration aDTWConfig)
        {
            List <double> lScores = new List <double>();

            foreach (Signature sig in aSignatures)
            {
                int    lCounter = 0;
                double lScore   = 0;
                foreach (Signature refSig in aTemplate)
                {
                    lScore += ConfigurableDTW.DTWDistance(refSig, sig, aDTWConfig);
                    ++lCounter;
                }
                lScore /= lCounter;
                lScores.Add(lScore);
            }
            return(lScores);
        }
        /// <summary>
        /// Removes the worst aNrOfSamplesToRemove samples from the template
        /// </summary>
        /// <param name="aDirectory"></param>
        /// <param name="aNrOfSamplesToRemove"></param>
        /// <param name="aDTWConfig"></param>
        /// <param name="aTolerance"></param>
        public static void RemoveWorstSamples(string aDirectory, int aNrOfSamplesToRemove, DTWConfiguration aDTWConfig, double aTolerance = 0.05)
        {
            List <Signature> lSignaturesOfUser = SignatureFileUtils.GetAllSignaturesFromFolder(aDirectory, true);

            List <double>         lListOfAverageOfScores = new List <double>();
            List <List <double> > lListOfScores          = new List <List <double> >();

            //Compare all signatures to the rest, one by one and save the scores in a matrix
            for (int i = 0; i < lSignaturesOfUser.Count; ++i)
            {
                var lSigToCompare = lSignaturesOfUser.ElementAt(i);

                List <double> lResults = new List <double>();
                for (int j = 0; j < lSignaturesOfUser.Count; ++j)
                {
                    var lSig = lSignaturesOfUser.ElementAt(j);
                    lResults.Add(ConfigurableDTW.DTWDistance(lSigToCompare, lSig, aDTWConfig));
                }
                lListOfScores.Add(lResults);
            }

            //Calculate the average of the scores
            for (int i = 0; i < lListOfScores.Count; ++i)
            {
                for (int j = 0; j < lListOfScores.ElementAt(i).Count; ++i)
                {
                    if (i == 0)
                    {
                        lListOfAverageOfScores.Add(lListOfScores[i][j]);
                    }
                    else
                    {
                        lListOfAverageOfScores[j] += lListOfScores[i][j];
                    }
                }
            }
            for (int i = 0; i < lListOfAverageOfScores.Count; ++i)
            {
                lListOfAverageOfScores[i] /= lListOfAverageOfScores.Count;
            }

            //Remove the worst samples
            for (int i = 0; i < aNrOfSamplesToRemove; ++i)
            {
                //delete the signature files from disk
                var lIndexToRemove = lListOfAverageOfScores.IndexOf(lListOfAverageOfScores.Max());
                File.Delete(lSignaturesOfUser.ElementAt(lIndexToRemove).Filename);
            }
        }
예제 #13
0
        public static double CompareMCYTFusion(string aFolder, int aNrOfTrainingSamples, DTWConfiguration aDTWConfig, ref StreamWriter aSWriter)
        {
            List <Signature> lSignatures = SignatureFileUtils.GetAllSignaturesFromFolder(aFolder);

            List <Signature> lTemplate           = lSignatures.Skip(25).Take(aNrOfTrainingSamples).ToList();
            List <Signature> lOriginalSignatures = lSignatures.Skip(25 + aNrOfTrainingSamples).Take(25 - aNrOfTrainingSamples).ToList();
            List <Signature> lImpostorSignatures = lSignatures.Take(15).ToList();

            //retrieve feature set
            List <SignatureFeatures> lFeaturesTemplate = new List <SignatureFeatures>();
            List <SignatureFeatures> lFeaturesOriginal = new List <SignatureFeatures>();
            List <SignatureFeatures> lFeaturesImpostor = new List <SignatureFeatures>();

            for (int i = 0; i < lTemplate.Count; ++i)
            {
                var lElement    = lTemplate.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lTemplate.RemoveAt(i);
                lTemplate.Insert(i, lNewElement);

                lFeaturesTemplate.Add(FeatureCalculator.CalculateFeatures(lNewElement));
            }

            for (int i = 0; i < lOriginalSignatures.Count; ++i)
            {
                var lElement    = lOriginalSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lOriginalSignatures.RemoveAt(i);
                lOriginalSignatures.Insert(i, lNewElement);

                lFeaturesOriginal.Add(FeatureCalculator.CalculateFeatures(lNewElement));
            }

            for (int i = 0; i < lImpostorSignatures.Count; ++i)
            {
                var lElement    = lImpostorSignatures.ElementAt(i);
                var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                lImpostorSignatures.RemoveAt(i);
                lImpostorSignatures.Insert(i, lNewElement);

                lFeaturesImpostor.Add(FeatureCalculator.CalculateFeatures(lNewElement));
            }

            ManhattanDetector lEuclideanDetector = new ManhattanDetector(lFeaturesTemplate);

            List <double> lListOfScores = new List <double>();

            //aDetector.CalculateScores()
            List <double> lOriginalScoresGlobal = lEuclideanDetector.CompareToTemplate(lFeaturesOriginal);
            List <double> lImpostorScoresGlobal = lEuclideanDetector.CompareToTemplate(lFeaturesImpostor);

            //int lNumberOfOriginalScores;
            //int lNumberOfImpostorScores;

            //lListOfScores.AddRange(lOriginalScoresGlobal);
            //lListOfScores.AddRange(lImpostorScoresGlobal);

            //lListOfScores = SignatureUtils.SignatureUtils.MinMaxNormalization(lListOfScores);

            //lNumberOfOriginalScores = lOriginalScoresGlobal.Count;
            //lNumberOfImpostorScores = lImpostorScoresGlobal.Count;

            //lOriginalScoresGlobal = new List<double>();
            //lOriginalScoresGlobal.AddRange(lListOfScores.Take(lNumberOfOriginalScores));

            //lImpostorScoresGlobal = new List<double>();
            //lImpostorScoresGlobal.AddRange(lListOfScores.Skip(lNumberOfOriginalScores).Take(lNumberOfImpostorScores));

            List <double> lOriginalScoresLocal = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lOriginalSignatures, aDTWConfig);
            List <double> lImpostorScoresLocal = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lImpostorSignatures, aDTWConfig);


            aSWriter.WriteLine("Original Scores Local" + "," + "Original Scores Global");
            for (int i = 0; i < lOriginalScoresLocal.Count; ++i)
            {
                aSWriter.WriteLine(lOriginalScoresLocal.ElementAt(i) + "," + lOriginalScoresGlobal.ElementAt(i));
            }


            //lListOfScores = new List<double>();
            //lListOfScores.AddRange(lOriginalScoresLocal);
            //lListOfScores.AddRange(lImpostorScoresLocal);

            //lListOfScores = SignatureUtils.SignatureUtils.MinMaxNormalization(lListOfScores);

            //lNumberOfOriginalScores = lOriginalScoresLocal.Count;
            //lNumberOfImpostorScores = lImpostorScoresLocal.Count;

            //lOriginalScoresLocal = new List<double>();
            //lOriginalScoresLocal.AddRange(lListOfScores.Take(lNumberOfOriginalScores));

            //lImpostorScoresLocal = new List<double>();
            //lImpostorScoresLocal.AddRange(lListOfScores.Skip(lNumberOfOriginalScores).Take(lNumberOfImpostorScores));

            aSWriter.WriteLine("Impostor Scores Local" + "," + "Impostor Scores Global");
            for (int i = 0; i < lImpostorScoresLocal.Count; ++i)
            {
                aSWriter.WriteLine(lImpostorScoresLocal.ElementAt(i) + "," + lImpostorScoresGlobal.ElementAt(i));
            }

            //List<double> lOriginalScores = SignatureUtils.SignatureUtils.ScoreFusion(lOriginalScoresLocal, lOriginalScoresGlobal);
            //List<double> lImpostorScores = SignatureUtils.SignatureUtils.ScoreFusion(lImpostorScoresLocal, lImpostorScoresGlobal);

            //aSWriter.WriteLine("Impostor Scores");
            //for (int i = 0; i < lImpostorScores.Count; ++i)
            //{
            //    aSWriter.WriteLine(lImpostorScores.ElementAt(i));
            //}

            //aSWriter.WriteLine("Original Scores");
            //for (int i = 0; i < lOriginalScores.Count; ++i)
            //{
            //    aSWriter.WriteLine(lOriginalScores.ElementAt(i));
            //}

            //ErrorCalculation lError = ErrorCalculationFactory.GetDScoreErrorCalculator();
            //lError.CalculateErrors(lOriginalScores, lImpostorScores, 100);

            //var lFARList = lError.GetFARList();
            //var lFRRList = lError.GetFRRList();
            //var lTresholdList = lError.GetThresholdList();

            //for(int i = 0; i < lFARList.Count; ++i)
            //{
            //    aSWriter.WriteLine(lFARList.ElementAt(i) + "," + lFRRList.ElementAt(i) + ", " + lTresholdList.ElementAt(i));
            //}

            //for (int i = 0; i < lOriginalScoresLocal.Count; ++i)
            //{
            //    aSWriter.WriteLine(lOriginalScoresLocal.ElementAt(i) + "," + lOriginalScoresGlobal.ElementAt(i));
            //}

            //aSWriter.WriteLine(lError.GetERR());

            return(1);
        }
        static void Main(string[] args)
        {
            StreamWriter     file1      = new StreamWriter("d:\\" + "Result_MOBISIG_Scores_" + DateTime.Now.Ticks.ToString() + ".csv");
            DTWConfiguration lDTWConfig = new DTWConfiguration();

            List <double> lAllOriginalScoresGlobal  = new List <double>();
            List <double> lAllOriginalScoresGlobal2 = new List <double>();
            List <double> lAllOriginalScoresLocal   = new List <double>();

            List <double> lAllImpostorScoresGlobal  = new List <double>();
            List <double> lAllImpostorScoresGlobal2 = new List <double>();
            List <double> lAllImpostorScoresLocal   = new List <double>();


            Console.Write("Path to directory: ");
            string lPath = Console.ReadLine();

            string[] lSubdirectoryEntries = Directory.GetDirectories(lPath);


            lDTWConfig = new DTWConfiguration()
                         .UseXY()
                         .UseX1Y1()
                         .UseX2Y2();

            int aNrOfTrainingSamples = 10;

            foreach (var directory in lSubdirectoryEntries)
            {
                Console.WriteLine("Processing " + directory + " directory");

                List <Signature> lSignatures = SignatureFileUtils.GetAllSignaturesFromFolder(directory);

                //MCYT
                //List<Signature> lTemplate = lSignatures.Skip(25).Take(aNrOfTrainingSamples).ToList();
                //List<Signature> lOriginalSignatures = lSignatures.Skip(25 + aNrOfTrainingSamples).Take(25 - aNrOfTrainingSamples).ToList();
                //List<Signature> lImpostorSignatures = lSignatures.Take(15).ToList();

                //MOBISIG
                List <Signature> lTemplate           = lSignatures.Skip(20).Take(aNrOfTrainingSamples).ToList();
                List <Signature> lOriginalSignatures = lSignatures.Skip(20 + aNrOfTrainingSamples).Take(25 - aNrOfTrainingSamples).ToList();
                List <Signature> lImpostorSignatures = lSignatures.Take(15).ToList();

                //retrieve feature set
                List <SignatureFeatures> lFeaturesTemplate = new List <SignatureFeatures>();
                List <SignatureFeatures> lFeaturesOriginal = new List <SignatureFeatures>();
                List <SignatureFeatures> lFeaturesImpostor = new List <SignatureFeatures>();

                for (int i = 0; i < lTemplate.Count; ++i)
                {
                    var lElement    = lTemplate.ElementAt(i);
                    var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                    lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                    lTemplate.RemoveAt(i);
                    lTemplate.Insert(i, lNewElement);

                    lFeaturesTemplate.Add(FeatureCalculator.CalculateFeatures(lNewElement));
                }

                for (int i = 0; i < lOriginalSignatures.Count; ++i)
                {
                    var lElement    = lOriginalSignatures.ElementAt(i);
                    var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                    lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                    lOriginalSignatures.RemoveAt(i);
                    lOriginalSignatures.Insert(i, lNewElement);

                    lFeaturesOriginal.Add(FeatureCalculator.CalculateFeatures(lNewElement));
                }

                for (int i = 0; i < lImpostorSignatures.Count; ++i)
                {
                    var lElement    = lImpostorSignatures.ElementAt(i);
                    var lNewElement = SignatureUtils.SignatureUtils.CalculateCharacteristics(lElement);

                    lNewElement = SignatureUtils.SignatureUtils.StandardizeSignature(lNewElement);

                    lImpostorSignatures.RemoveAt(i);
                    lImpostorSignatures.Insert(i, lNewElement);

                    lFeaturesImpostor.Add(FeatureCalculator.CalculateFeatures(lNewElement));
                }

                ManhattanDetector lManhattanDetector = new ManhattanDetector(lFeaturesTemplate);
                EuclideanDetector lEuclideanDetector = new EuclideanDetector(lFeaturesTemplate);

                List <double> lListOfScores = new List <double>();

                //aDetector.CalculateScores()
                List <double> lOriginalScoresGlobal = lManhattanDetector.CompareToTemplate(lFeaturesOriginal);
                List <double> lImpostorScoresGlobal = lManhattanDetector.CompareToTemplate(lFeaturesImpostor);

                List <double> lOriginalScoresGlobal2 = lEuclideanDetector.CompareToTemplate(lFeaturesOriginal);
                List <double> lImpostorScoresGlobal2 = lEuclideanDetector.CompareToTemplate(lFeaturesImpostor);

                List <double> lOriginalScoresLocal = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lOriginalSignatures, lDTWConfig);
                List <double> lImpostorScoresLocal = SignatureUtils.SignatureUtils.CompareSignaturesDTW(lTemplate, lImpostorSignatures, lDTWConfig);


                lAllOriginalScoresGlobal.AddRange(lOriginalScoresGlobal);
                lAllOriginalScoresGlobal2.AddRange(lOriginalScoresGlobal2);
                lAllOriginalScoresLocal.AddRange(lOriginalScoresLocal);
                lAllImpostorScoresGlobal.AddRange(lImpostorScoresGlobal);
                lAllImpostorScoresGlobal2.AddRange(lImpostorScoresGlobal2);
                lAllImpostorScoresLocal.AddRange(lImpostorScoresLocal);
            }

            file1.WriteLine("Original Scores Local" + "," + "Original Scores Manhattan" + "," + "Original Scores Euclidean");
            for (int i = 0; i < lAllOriginalScoresLocal.Count; ++i)
            {
                file1.WriteLine(lAllOriginalScoresLocal.ElementAt(i) + "," + lAllOriginalScoresGlobal.ElementAt(i) + "," + lAllOriginalScoresGlobal2.ElementAt(i));
            }

            file1.WriteLine("Impostor Scores Local" + "," + "Impostor Scores Manhattan" + "," + "Impostor Scores Euclidean");
            for (int i = 0; i < lAllImpostorScoresLocal.Count; ++i)
            {
                file1.WriteLine(lAllImpostorScoresLocal.ElementAt(i) + "," + lAllImpostorScoresGlobal.ElementAt(i) + "," + lAllImpostorScoresGlobal2.ElementAt(i));
            }

            file1.Close();
        }