public override void BeginTemplating(CaptureInfo capture)
            {
                // Prepare to start templating a new capture
                // Clear the UI of any previous work
                Outer.m_DispatcherHelper.Invoke(new Action(() =>
                {
                    Outer.Minutae.Clear();
                }));

                // Record the new capture
                Outer.Capture = capture;
                if (Outer.Capture.TemplateData != null)
                {
                    // If there is a template in the capture info, load it.
                    IEnumerable <MinutiaRecord> template = IsoTemplateHelper
                                                           .ToMinutae(Outer.Capture.TemplateData);
                    foreach (MinutiaRecord rec in template)
                    {
                        // Ensure we use the UI thread to add to the ObservableCollection.
                        App.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            Outer.Minutae.Add(rec);
                        }));
                    }
                }
                TransitionTo(typeof(WaitLocation));
            }
Beispiel #2
0
        private void TestToIsoTemplate(IEnumerable <MinutiaRecord> minutae, string isoTemplateHex)
        {
            // Get the IsoTemplate
            byte[] template = IsoTemplateHelper.ToIsoTemplate(minutae);
            // Convert the IsoTemplate back to a list of minutia (loss of data in casting)
            IEnumerable <MinutiaRecord> convert_minutae = IsoTemplateHelper.ToMinutae(template);

            // Convert it to Hex for comparison
            string templateHex = BitConverter.ToString(template);

            templateHex = templateHex.Replace("-", String.Empty);

            // Assertions
            CollectionAssert.AreEqual(IsoTemplateHelper.ToByteArray(isoTemplateHex), template);
            Assert.AreEqual(minutae.Count(), convert_minutae.Count());
            for (int i = 0; i < convert_minutae.Count(); i++)
            {
                MinutiaRecord real_minutia      = minutae.ElementAt(i);
                MinutiaRecord converted_minutia = convert_minutae.ElementAt(i);
                Assert.AreEqual((int)real_minutia.Position.X, converted_minutia.Position.X);
                Assert.AreEqual((int)real_minutia.Position.Y, converted_minutia.Position.Y);
                // y(x,a) = ax - floor(ax)
                // max(y(x,a)) = 1, min(y(x,a)) = 0
                // e(x,a) = x - x_hat =  1/a * floor(ax) = 1/a * y(x,a)
                // Thus max(e(x,a)) = 1/a, min(e(x,a)) = 0
                Assert.IsTrue(real_minutia.Angle - converted_minutia.Angle < 1.0 / (256 / 360));
            }
        }