示例#1
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);
            }
        }