Exemple #1
0
        public void ValidateTldTest(string tldStr, string expected)
        {
            Tld tld = Tld.FromString(tldStr);

            Output.WriteLine($"Expected: {tldStr}, Output: {tld.Code}");
            Assert.Equal(expected, tld.Code);
        }
Exemple #2
0
        public static bool IsValidEmailAddress(string address)
        {
            try
            {
                MailAddress mailAddress = GetEmailAddress(address);
                string      tld         = Regex.Match(mailAddress.Address, @"\.(?<tld>[a-z]{2,})$", RegexOptions.IgnoreCase).Groups["tld"].Value;
                if (Tld.IsValid(tld))
                {
                    return(true);
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }
Exemple #3
0
        public static ITld Instantiate()
        {
            IObjectModel      objectModel = LoadObjectModel();
            MedianFlowTracker tracker     = LoadTracker();
            IDetector         detector    = LoadDetector(objectModel);
            ILearner          learner     = LoadLearner(objectModel, detector);

            ITld tld = new Tld(
                objectModel,
                tracker,
                learner,
                detector,
                new ZdenekOutputStrategy(objectModel, learner)
                );

            tld.PostInstantiation();

            return(tld);
        }
Exemple #4
0
 private bool IsGoogleDomain(Uri url)
 {
     if (url.IsHostedOn("google.it"))
     {
         return(true);
     }
     if (url.IsHostedOn("google.com"))
     {
         return(true);
     }
     if (!url.Host.Contains("google"))
     {
         return(false);
     }
     if (Tld.GetDomainFromUrl(url).StartsWith("google."))
     {
         return(true);
     }
     return(false);
 }
Exemple #5
0
        public void DetectObject_DetectorAndLearnerInteraction()
        {
            // arrange - instantiate tld
            Tld tld = Persistor.LoadTld(Path.Combine(_resourceDir, "tld.xml")) as Tld;

            // arrange - load init frame
            Image <Gray, byte> initFrame = new Image <Gray, byte>(Path.Combine(_resourceDir, "face_frame1.png"));

            // arrange - define init bounding box
            BoundingBox initBb = new BoundingBox(new PointF(286, 271), new SizeF(172, 143));

            // arrange - initialize TLD
            tld.Initialize(initFrame, initBb);

            // arrange - load second frame
            Image <Gray, byte> frame2 = new Image <Gray, byte>(Path.Combine(_resourceDir, "face_frame2.png"));

            // arrange - call 'FindObject' on TLD
            tld.FindObject(frame2);

            // define expected
            IBoundingBox expected = new BoundingBox(new PointF(285, 258), new SizeF(169, 136));

            // get actual
            List <IBoundingBox> detectorOutputs = tld.Detector.Detections;

            // assert - CAN FAIL !!! - detector should find the object
            Assert.IsTrue(detectorOutputs.Count >= 1);
            float expectedOverlap = 0.85f;

            foreach (IBoundingBox output in detectorOutputs)
            {
                float overlap = output.GetOverlap(expected);
                Assert.AreEqual(expectedOverlap, overlap, 0.15f);
            }
        }
Exemple #6
0
 public Url(Tld tld, string domainName, string subdomain, string scheme, string path) : this(new Domain(domainName, tld), subdomain, scheme, path)
 {
 }
Exemple #7
0
 public Domain(string domain, Tld tld) : this()
 {
     this.DomainName = domain;
     this.Tld        = tld;
 }
Exemple #8
0
 public void InvalidTldTest()
 {
     Assert.Throws <InvalidTopLevelDomainException>(
         () => Tld.FromString("DOESNOTEXISTS")
         );
 }