Example #1
0
        public static void Calculate(string[] ids, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();

            var offlinePipeline = FusionPipelines.GetOfflinePipeline();
            var onlinePipeline  = FusionPipelines.GetOnlinePipeline();
            var fusionPipeline  = FusionPipelines.GetFusionPipeline(onlineSigners, false, 0);

            foreach (var offSigner in offlineSigners)
            {
                Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    offlinePipeline.Transform(offSig);
                    var onSig          = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                    var onToOnPipeline = FusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                    onToOnPipeline.Transform(onSig);
                    onlinePipeline.Transform(onSig);
                }
                                 );

                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    fusionPipeline.Transform(offSig);
                    onlinePipeline.Transform(offSig);
                }
                                 );

                var distViewer = FusionPipelines.GetDistanceMatrixViewer(onSigner.Signatures, offSigner.Signatures);
                TxtHelper.Save(TxtHelper.ArrayToLines(distViewer.Calculate()), "distancematrix" + offSigner.ID);
            }
        }
Example #2
0
        public static void Calculate(string[] ids, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();


            var offlinePipeline = FusionPipelines.GetOfflinePipeline();

            foreach (var offSigner in offlineSigners)
            {
                Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    Console.WriteLine("Preprocess - " + offSig.Signer.ID + "_" + offSig.ID + "started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    offlinePipeline.Transform(offSig);
                    var onSig          = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                    var onToOnPipeline = FusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                    onToOnPipeline.Transform(onSig);
                }
                                 );

                int numOfRef   = 10;
                int numOfGen   = 20;
                var references = onSigner.Signatures.FindAll(sig => sig.Origin == Origin.Genuine).Take(numOfRef).ToList();
                var genuines   = offSigner.Signatures.FindAll(sig => sig.Origin == Origin.Genuine).Take(numOfGen).ToList();

                double[,] results = new double[references.Count, genuines.Count];

                for (int i = 0; i < references.Count; i++)
                {
                    var fusionPipeline = FusionPipelines.GetFusionPipeline(onlineSigners, false, i);
                    Parallel.For(0, genuines.Count, j =>
                    {
                        Console.WriteLine("ref: {0}, sig: {1}", i, j);
                        fusionPipeline.Transform(genuines[j]);
                    }
                                 );
                    var pairingDists = new StrokePairingDistances
                    {
                        InputOfflineTrajectory = FusionFeatures.Trajectory,
                        InputOnlineTrajectory  = FusionFeatures.Trajectory,
                        OnlineSignatures       = onSigner.Signatures,
                        OfflineSignatures      = genuines
                    };
                    var newDists = pairingDists.Calculate();
                    if (newDists.Count != results.GetLength(1))
                    {
                        throw new Exception();
                    }
                    for (int j = 0; j < newDists.Count; j++)
                    {
                        results[i, j] = newDists[j].Item3;
                        Console.WriteLine(results[i, j]);
                    }
                }
                TxtHelper.Save(TxtHelper.ArrayToLines(results), "pairingmatrix" + offSigner.ID);
            }
        }
Example #3
0
        public static void CalculateForID(string[] ids, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners(signer => ids.Contains(signer.ID)).ToList();


            var offlinePipeline = FusionPipelines.GetOfflinePipeline();
            var fusionPipeline  = FusionPipelines.GetFusionPipeline(onlineSigners, false, 0);

            foreach (var offSigner in offlineSigners)
            {
                Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    Console.WriteLine("Preprocess - " + offSig.Signer.ID + "_" + offSig.ID + "started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    offlinePipeline.Transform(offSig);
                    var onSig           = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                    var onToOffPipeline = FusionPipelines.GetOnlineToOfflinePipeline(offSig.GetFeature(FusionFeatures.Bounds));
                    onToOffPipeline.Transform(onSig);
                }
                                 );

                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    Console.WriteLine("Process - " + offSig.Signer.ID + "_" + offSig.ID + "started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    fusionPipeline.Transform(offSig);
                }
                                 );
            }

            foreach (var offSigner in offlineSigners)
            {
                var onSigner     = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                var pairingDists = new StrokePairingDistances
                {
                    InputOfflineTrajectory = FusionFeatures.Trajectory,
                    InputOnlineTrajectory  = FusionFeatures.BaseTrajectory,
                    OfflineSignatures      = offSigner.Signatures,
                    OnlineSignatures       = onSigner.Signatures
                };
                pairingDists.Calculate();
            }
        }
        public static BenchmarkResults BenchMarkingWithAllSigners(bool isoptimal, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners().ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners().ToList();

            var benchmark = FusionPipelines.GetBenchmark(offlineSigners, isoptimal);

            var offlinePipeline = FusionPipelines.GetOfflinePipeline();
            var onlinePipeline  = FusionPipelines.GetOnlinePipeline();
            var fusionPipeline  = FusionPipelines.GetFusionPipeline(onlineSigners, false, 0);


            foreach (var offSigner in offlineSigners)
            {
                Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    offlinePipeline.Transform(offSig);
                    var onSig          = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                    var onToOnPipeline = FusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                    onToOnPipeline.Transform(onSig);
                    onlinePipeline.Transform(onSig);
                }
                                 );
                Parallel.ForEach(offSigner.Signatures, offSig =>
                {
                    fusionPipeline.Transform(offSig);
                    onlinePipeline.Transform(offSig);
                }
                                 );


                var listWithOnlySigner = new List <Signer>()
                {
                    offSigner
                };
                var onlySigBenchmark = FusionPipelines.GetBenchmark(listWithOnlySigner, true);
                var onlyRes          = onlySigBenchmark.Execute();
                TxtHelper.Save(TxtHelper.BenchmarkResToLines(onlyRes), "offoff" + offSigner.ID);
            }
            return(benchmark.Execute());
        }
Example #5
0
        public static FusionBenchmarkResults BenchMarkingWithAllSigners(bool isoptimal, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners().ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners().ToList();


            var offlinePipeline = FusionPipelines.GetOfflinePipeline();
            var onlinePipeline  = FusionPipelines.GetOnlinePipeline();
            var fusionPipeline  = FusionPipelines.GetFusionPipeline(onlineSigners, false, 0);

            var offOnSigners = new List <Signer>();
            var onOffSigners = new List <Signer>();

            Parallel.ForEach(offlineSigners, offSigner =>
            {
                try
                {
                    Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        offlinePipeline.Transform(offSig);
                        var onSig = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                        onSig.SetFeature <Image <Rgba32> >(FusionFeatures.Image, offSig.GetFeature(FusionFeatures.Image));
                        var onToOnPipeline = FusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                        onToOnPipeline.Transform(onSig);
                        onlinePipeline.Transform(onSig);
                    }
                                     );
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        fusionPipeline.Transform(offSig);
                        onlinePipeline.Transform(offSig);
                    }
                                     );

                    var offonSigner = FusionPipelines.GetMixedSigner(offSigner, onSigner);
                    var onoffSigner = FusionPipelines.GetMixedSigner(onSigner, offSigner);
                    offOnSigners.Add(offonSigner);
                    onOffSigners.Add(onoffSigner);
                    Console.WriteLine(offSigner.ID + " finished at " + DateTime.Now.ToString("h:mm:ss tt"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
                             );


            var offoffBenchmark = FusionPipelines.GetBenchmark(offlineSigners, isoptimal);
            var offonBenchmark  = FusionPipelines.GetBenchmark(offOnSigners, isoptimal);
            var onoffBenchamrk  = FusionPipelines.GetBenchmark(onOffSigners, isoptimal);
            var ononBenchmark   = FusionPipelines.GetBenchmark(onlineSigners, isoptimal);


            return(new FusionBenchmarkResults
            {
                OffOffResults = offoffBenchmark.Execute(),
                OffOnResults = offonBenchmark.Execute(),
                OnOffResults = onoffBenchamrk.Execute(),
                OnOnResults = ononBenchmark.Execute()
            });
        }