Ejemplo n.º 1
0
        public void ReturnsFalseOngameplay()
        {
            // All the of the test frames in ./1080 should be from game stills so never black
            string[] filePaths  = Directory.GetFiles("./Test/testdata/frames/1080/gameplay", "*.png", SearchOption.TopDirectoryOnly);
            byte[]   data       = new byte[1080 * 1920 * 3];
            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            foreach (string fn in filePaths)
            {
                if (fn.Contains("clear_"))
                {
                    continue;
                }
                var testFrame = new Image <Bgr, byte>(fn);

                // Test frame MUST be 1920x1080 otherwise a black frame will be returned with no errors or warnings
                Assert.IsTrue(testFrame.Size.Width == 1920);
                Assert.IsTrue(testFrame.Size.Height == 1080);

                Mat currentFrame = new Mat(testFrame.Size, DepthType.Cv8U, 3, dataHandle.AddrOfPinnedObject(), testFrame.Width * 3);
                testFrame.Mat.CopyTo(currentFrame);
                var hues = VideoProcessor.getHues(data, testFrame.Size);
                Assert.IsFalse(VideoProcessor.isClearFrame(hues));
            }
        }
Ejemplo n.º 2
0
        public void ReturnsTrueOnClearFrames()
        {
            string[] filePaths = Directory.GetFiles("./Test/testdata/frames/1080/", "clear_*.png", SearchOption.TopDirectoryOnly);

            byte[]   data       = new byte[1080 * 1920 * 3];
            GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            foreach (string fn in filePaths)
            {
                var testFrame = new Image <Bgr, byte>(fn);

                // Test frame MUST be 1920x1080 otherwise a black frame will be returned with no errors or warnings
                Assert.IsTrue(testFrame.Size.Width == 1920);
                Assert.IsTrue(testFrame.Size.Height == 1080);

                Mat currentFrame = new Mat(testFrame.Size, DepthType.Cv8U, 3, dataHandle.AddrOfPinnedObject(), testFrame.Width * 3);
                testFrame.Mat.CopyTo(currentFrame);
                var hues = VideoProcessor.getHues(data, testFrame.Size);
                Assert.IsTrue(VideoProcessor.isClearFrame(hues));
            }

            dataHandle.Free();
        }