Пример #1
0
        public void getVideoHandlerTest()
        {
            Thread.Sleep(30000); // pluginmanager needs time for consistency check
            YuvVideoInfo info = new YuvVideoInfo(sampleVideos[2]);
            Video target = new Video(false, sampleVideos[2], info, null);
            IVideoHandler expected = new YuvVideoHandler();
            expected.setReadContext(sampleVideos[2], info);
            IVideoHandler actual = target.handler;
            Assert.AreEqual(expected.readPath, actual.readPath);
            Assert.AreEqual(expected.readVidInfo, actual.readVidInfo);
            IVideoHandler extra = target.getExtraHandler();
            Assert.AreEqual(extra.readPath, actual.readPath);
            Assert.AreEqual(extra.readVidInfo, actual.readVidInfo);
            Video target2 = new Video(false, sampleVideos[2], null, null);
            IVideoHandler actual2 = target2.handler;
            string falsePath
                = "D:\\Documents and Settings\\fenix1\\OQAT\\Implementierung\\OQAT_Tests\\TestData\\sampleVideos\\about.txt";
            Video fakeVideo = new Video(false, falsePath, null, null);
            try
            {
                IVideoHandler noHandler = fakeVideo.handler;
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
        }
Пример #2
0
 public void flushWriterTest()
 {
     YuvVideoHandler yvh = new YuvVideoHandler();
     YuvVideoInfo info = new YuvVideoInfo(readPath);
     info.width = 352;
     info.height = 240;
     info.yuvFormat = YuvFormat.YUV420_IYUV;
     yvh.setReadContext(readPath, info); // write context cannot be set without a valid read context
     writePath = sampleVideosPath + "\\americanFootball_352x240_125_Copy.yuv";
     YuvVideoInfo writeinfo = new YuvVideoInfo();
     writeinfo.path = writePath;
     writeinfo.width = 352;
     writeinfo.height = 240;
     writeinfo.yuvFormat = YuvFormat.YUV420_IYUV;
     yvh.setWriteContext(writePath, writeinfo);
     int oldFrameByteSize = yvh.frameByteSize;
     yvh.flushWriter();
     Assert.AreEqual(oldFrameByteSize, yvh.frameByteSize);
     Assert.AreEqual(0, yvh.positionReader);
     System.Drawing.Bitmap testframe = yvh.getFrame();
     System.Drawing.Bitmap[] frames = new System.Drawing.Bitmap[1];
     frames[0] = testframe;
     yvh.writeFrames(4, frames);
     yvh.flushWriter();
     yvh.writeFrames(4, frames);
 }
Пример #3
0
 public ReadOnlyPropertiesView(YuvVideoInfo yuvInfo)
 {
     InitializeComponent();
     if (yuvInfo == null)
         throw new NullReferenceException("Given YuvVideoInfo object is not initialized.");
     this.DataContext = yuvInfo;
     this.local("YufVideoHandler_" + Thread.CurrentThread.CurrentCulture + ".xml");
 }
Пример #4
0
 public void cloneTest()
 {
     path = sampleVideos[2];
     YuvVideoInfo info2 = new YuvVideoInfo(path);
     YuvVideoInfo info1 = (YuvVideoInfo)info2.Clone();
     Assert.AreEqual(info1.width, info2.width);
     Assert.AreEqual(info1.height, info2.height);
     Assert.AreEqual(info1.yuvFormat, info2.yuvFormat);
 }
Пример #5
0
        public void clampToByteTest()
        {
            YuvVideoInfo info = new YuvVideoInfo();
            YuvVideoHandler handler = new YuvVideoHandler();
            handler.setVideo(TESTVIDEO_PATH, info);

            PrivateObject param0 = new PrivateObject(handler);
            YuvVideoHandler_Accessor target = new YuvVideoHandler_Accessor(param0);

            int[] val = new int[]        { -1, 128, 0, 255, 256, 500, int.MaxValue,  int.MinValue };
            byte[] expected = new byte[] {  0, 128, 0, 255, 255, 255, 255,           0};

            for (int i = 0; i < expected.Length; i++)
            {
                byte actual;
                actual = target.clampToByte(val[i]);
                Assert.AreEqual(expected[i], actual);
            }
        }
Пример #6
0
        public void constructorTest()
        {
            path = sampleVideos[2];
            YuvVideoInfo info1 = new YuvVideoInfo();
            info1.width = 352;
            info1.height = 288;
            info1.yuvFormat = YuvFormat.YUV420_IYUV;
            YuvVideoInfo info2 = new YuvVideoInfo(path);
            Assert.AreEqual(info1.width, info2.width);
            Assert.AreEqual(info1.height, info2.height);
            Assert.AreEqual(info1.yuvFormat, info2.yuvFormat);
            Assert.IsTrue(info1.Equals(info2));
            try
            {
                YuvVideoInfo falseInfo = new YuvVideoInfo("D:\\bla_cif.yuv");
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
        }
Пример #7
0
 public void constructorTest()
 {
     YuvVideoInfo info = new YuvVideoInfo(sampleVideos[2]);
     bool isana = false;
     Video target = new Video(false, sampleVideos[2], info, null);
     Assert.AreEqual(sampleVideos[2], target.vidPath);
     Assert.AreEqual(isana, target.isAnalysis);
     Assert.AreEqual(info, target.vidInfo);
     Dictionary<PresentationPluginType, List<string>> er
         = new Dictionary<PresentationPluginType, List<string>>();
     List<string> li = new List<string>();
     li.Add("testcustom");
     er.Add(PresentationPluginType.Custom, li);
     target.extraResources = er;
     float[][] metrics = new float[][] { new float[] { 1, 2, 3, 4, 5 } };
     target.frameMetricValue = metrics;
     List<IMacroEntry> macros = new List<IMacroEntry>();
     target.processedBy = macros;
     Assert.AreEqual(macros, target.processedBy);
     Assert.AreEqual(er, target.extraResources);
     Assert.AreEqual(metrics, target.frameMetricValue);
 }
Пример #8
0
        public void convertToRGB_Black_Test()
        {
            YuvVideoInfo info = new YuvVideoInfo();
            YuvVideoHandler handler = new YuvVideoHandler();
            handler.setVideo(TESTVIDEO_PATH, info);

            PrivateObject param0 = new PrivateObject(handler);
            YuvVideoHandler_Accessor target = new YuvVideoHandler_Accessor(param0);

            //Testing standard colors according to
            //http://msdn.microsoft.com/en-us/library/windows/desktop/bb530104%28v=vs.85%29.aspx
            int y = 16;
            int u = 128;
            int v = 128;
            Color expected = Color.Black;

            Color actual;
            actual = target.convertToRGB(y, u, v);

            Assert.AreEqual(expected.A, actual.A, "A not equal");
            Assert.AreEqual(expected.R, actual.R, "R not equal");
            Assert.AreEqual(expected.G, actual.G, "G not equal");
            Assert.AreEqual(expected.B, actual.B, "B not equal");
        }
Пример #9
0
        /// <summary>
        /// Creates a new set of indices for the current data array.
        /// </summary>
        public FrameDataPointers(YuvVideoInfo info)
        {
            _videoInfo = info;

            setFrameDataPointers();

            indexY = framedata_lum_start;
            indexU = framedata_u_start;
            indexV = framedata_v_start;
        }
Пример #10
0
        public void getFrameTest()
        {
            YuvVideoHandler_Accessor yvh = new YuvVideoHandler_Accessor();
            YuvVideoInfo info = new YuvVideoInfo(readPath);
            info.width = 352;
            info.height = 240;
            info.yuvFormat = YuvFormat.YUV420_IYUV;
            yvh.setReadContext(readPath, info);
            // yvh.setImportContext(readPath);
            // dangerous to use setimportcontext here, as it initializes a
            // yuv video info with the given path, without setting height/width
            int i = 0;
            System.Drawing.Bitmap testframe = null;
            while (yvh.positionReader < yvh.readVidInfo.frameCount)
            {
                try
                {
                    testframe = yvh.getFrame();
                }
                catch (Exception )
                {
                    Assert.Fail("Fail to get frame +" + i);
                }
                if (yvh.positionReader != i + 1)
                {
                    Assert.Fail("Reader possition is " + yvh.positionReader
                 + " while supposed to be " + i + 1);
                }
                if (testframe == null)
                {
                    Assert.Fail("Frame number " + i + " is null" +
                        " queuecount" + yvh.readQueue.Count);
                }
                if (testframe.Width != yvh.readVidInfo.width
                    || testframe.Height != yvh.readVidInfo.height)
                {
                    int[] param = new int[3] {i, testframe.Width,
                        testframe.Height};
                    Assert.Fail("Wrong frame size for frame "
                        + param[0] + ":" + param[1]
                        + "," + param[2]);
                }
                i++;
            }
            try
            {
                yvh.positionReader = 500;
                testframe = yvh.getFrame();
                Assert.Fail("no exception thrown");
            }
            catch (Exception )
            {

            }
        }
Пример #11
0
        public void vidInfoTest()
        {
            YuvVideoInfo info = new YuvVideoInfo();
            info.height = 666;

            YuvVideoHandler target =new YuvVideoHandler();
            target.setVideo(TESTVIDEO_PATH, info);
            IVideoInfo expected = info;
            IVideoInfo actual;
            actual = target.vidInfo;
            Assert.AreEqual(expected, actual);
        }
Пример #12
0
        public void importContextTest()
        {
            YuvVideoHandler yvh = new YuvVideoHandler();
            readPath = sampleVideos[2];
            YuvVideoInfo info = new YuvVideoInfo(readPath);
            yvh.setImportContext(readPath);
            Assert.AreEqual(info, yvh.readVidInfo);
            Assert.IsNotNull(yvh.frameByteSize);
            Assert.IsTrue(yvh.consistent);
            string falsePath = "\\bla_cif.yuv";
            try
            {
                yvh.setImportContext(falsePath);
                Assert.Fail("no exception thrown");
            }
            catch (Exception )
            {

            }
        }
Пример #13
0
        public void getFrameTest()
        {
            YuvVideoInfo info = new YuvVideoInfo();
            info.height = 144;
            info.width = 176;
            info.yuvFormat = YuvFormat.YUV420_IYUV;
            YuvVideoHandler target = new YuvVideoHandler();
            target.setVideo(TESTVIDEO_PATH, info);

            Bitmap expected = null;
            Bitmap actual;

            TestContext.BeginTimer("frame1");
            actual = target.getFrame(0);
            TestContext.EndTimer("frame1");

            TestContext.BeginTimer("frame2");
            actual = target.getFrame(1);
            TestContext.EndTimer("frame2");

            //TODO: How to compare this?!

            Assert.Inconclusive("Implement some way to check result first.");
        }
Пример #14
0
        public void readANDwriteFrameTest()
        {
            //init handler to read sample file
            YuvVideoInfo info_r = new YuvVideoInfo();
            info_r.height = 144;
            info_r.width = 176;
            info_r.yuvFormat = YuvFormat.YUV420_IYUV;
            YuvVideoHandler reader = new YuvVideoHandler();
            reader.setVideo(TESTVIDEO_PATH, info_r);

            //init handler to write a copy of sample file
            YuvVideoInfo info_w = new YuvVideoInfo();
            info_w.height = 144;
            info_w.width = 176;
            info_w.yuvFormat = YuvFormat.YUV420_IYUV;
            YuvVideoHandler writer = new YuvVideoHandler();
            writer.setVideo(TESTVIDEO_PATH + "copy", info_w);

            //copy sample file frame by frame
            //REMARK: This part can be commented out to save time once the copy is written to disk
            //          if this test is run several times to tweak parameters and error calculations
            for (int j = 0; j < ((YuvVideoInfo)reader.vidInfo).frameCount; j++)
            {
                Bitmap bmp = reader.getFrame(j);

                writer.writeFrame(j, bmp);
            }

            //
            //compare original file with the copy read and written by the handler
            //
            //TODO: Debug writeFrame() & getFrame() as there are significant differences when a copy of a file is created through YuvVideoHandlers

            //set buffersize to one frame
            int bsize =(int)( info_r.width * info_r.height * (1 + YuvVideoHandler.getLum2Chrom(info_r.yuvFormat)) );

            int error = 0;
            int errorcount = 0;

            FileStream fs1;
            fs1 = new FileStream(TESTVIDEO_PATH, FileMode.Open);
            byte[] data1 = new byte[bsize];
            FileStream fs2;
            fs2 = new FileStream(TESTVIDEO_PATH+"copy", FileMode.Open);
            byte[] data2 = new byte[bsize];

            //log files are written to the log folder with error information about frames and the whole file
            //because an unfulfilled assertion cancels the whole testrun
            StreamWriter log = new StreamWriter("C:/Dokumente und Einstellungen/Sebastian/Eigene Dateien/PSE/Implementierung/YuvVideoHandler/log/log.txt");

            //compare original and copy bytewise
            for (int i = 0; i < fs1.Length; i += bsize)
            {
                int r = fs1.Read(data1, 0, bsize);
                int r2 = fs2.Read(data2, 0, bsize);

                Assert.AreEqual(r, r2, "file read out of sync");

                //init log writer for this frame
                //the logfile of each frame contains the difference in value of original and copy for each byte
                //the diffs are written in the textfile as a matrix according to pixel position
                StreamWriter logdetail = new StreamWriter("C:/Dokumente und Einstellungen/Sebastian/Eigene Dateien/PSE/Implementierung/YuvVideoHandler/log/log"+(i/bsize)+".txt");

                for (int j = 0; j < r; j++)
                {
                    int diff = Math.Abs(data1[j] - data2[j]);

                    int y = j / info_r.width;
                    int x = j % info_r.width;

                    if (j % info_r.width == 0) logdetail.Write(logdetail.NewLine);

                    //Assert.IsTrue(diff < 5, "big difference at "+x+","+y+": "+diff);
                    logdetail.Write(diff+" ");
                    error += diff;
                    if (diff > 5) errorcount++;

                }

                logdetail.Close();

                //the global logfile is written with the accumulated information about this frame
                float errorratio = (((float)errorcount) / bsize);
                log.WriteLine("Frame: "+(i/bsize)+" / errorratio: "+errorratio);
                //Assert.IsTrue(error < 10, i+": error ratio: " + errorratio + " / error count: " + errorcount + " / accumulated error: " + error);

                error = 0;
                errorcount = 0;
            }

            log.Close();

            fs1.Close();
            fs2.Close();

            Assert.Inconclusive("Compare logfiles to determine errorrates");
        }
Пример #15
0
        public void convertToYUV_White_Test()
        {
            YuvVideoInfo info = new YuvVideoInfo();
            YuvVideoHandler handler = new YuvVideoHandler();
            handler.setVideo(TESTVIDEO_PATH, info);

            PrivateObject param0 = new PrivateObject(handler);
            YuvVideoHandler_Accessor target = new YuvVideoHandler_Accessor(param0);

            //Testing standard colors according to
            //http://msdn.microsoft.com/en-us/library/windows/desktop/bb530104%28v=vs.85%29.aspx
            int y = 235;
            int u = 128;
            int v = 128;

            byte[] actual;
            actual = target.convertToYUV(Color.White);

            Assert.AreEqual(y, actual[0], "Y not equal");
            Assert.AreEqual(u, actual[1], "U not equal");
            Assert.AreEqual(v, actual[2], "V not equal");
        }
Пример #16
0
 public void frameCountTest()
 {
     framecount = 150;
     path = sampleVideos[2];
     YuvVideoInfo info = new YuvVideoInfo(path);
     Assert.AreEqual(framecount, info.frameCount);
 }
Пример #17
0
        public void readContextTest()
        {
            YuvVideoHandler yvh = new YuvVideoHandler();
            Assert.AreEqual("yuvVideoHandler", yvh.namePlugin);
            Assert.AreEqual(PluginType.IVideoHandler, yvh.type);
            YuvVideoInfo info = new YuvVideoInfo(readPath);
            info.width = 352;
            info.height = 240;
            info.yuvFormat = YuvFormat.YUV420_IYUV;
            yvh.setReadContext(readPath, info);
            Assert.AreEqual(info, yvh.readVidInfo);
            Assert.IsNotNull(yvh.frameByteSize);
            //Assert.IsTrue(yvh.consistent);
            string falsePath = "\\bla_cif.yuv";
            YuvVideoInfo falseInfo = new YuvVideoInfo();
            falseInfo.path = falsePath;
            try
            {
                yvh.setReadContext(falsePath, falseInfo);
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
            try
            {
                yvh.setReadContext(falsePath, info);
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
            try
            {
                yvh.setReadContext(readPath, falseInfo);
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
        }
Пример #18
0
        public void writeContextTest()
        {
            YuvVideoHandler yvh = new YuvVideoHandler();
            YuvVideoInfo info = new YuvVideoInfo(readPath);
            info.width = 352;
            info.height = 240;
            info.yuvFormat = YuvFormat.YUV420_IYUV;

            yvh.setWriteContext(readPath, info);

            yvh.setReadContext(readPath, info);
            yvh.setWriteContext(readPath, info);
            Assert.AreEqual(info, yvh.writeVidInfo);
            Assert.IsTrue(yvh.consistent);
            string falsePath = "\\bla_cif.yuv";
            YuvVideoInfo falseInfo = new YuvVideoInfo();
            falseInfo.path = falsePath;
            try
            {
                yvh.setWriteContext(falsePath, falseInfo);
                Assert.Fail("no exception thrown");
            }
            catch (Exception )
            {

            }
            try
            {
                yvh.setWriteContext(falsePath, info);
                Assert.Fail("no exception thrown");
            }
            catch (Exception )
            {

            }
            try
            {
                yvh.setWriteContext(readPath, falseInfo);
                Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
        }
Пример #19
0
        public void writeFramesTest()
        {
            YuvVideoHandler_Accessor yvh = new YuvVideoHandler_Accessor();
            writePath = sampleVideosPath + "\\americanFootball_352x240_125_Copy.yuv";
            YuvVideoInfo info = new YuvVideoInfo();
            info.path = readPath;
            info.width = 352;
            info.height = 240;
            info.yuvFormat = YuvFormat.YUV420_IYUV;
            yvh.setReadContext(readPath, info); // write context cannot be set without a valid read context
            YuvVideoInfo writeinfo = new YuvVideoInfo();
            writeinfo.path = writePath;
            writeinfo.width = 352;
            writeinfo.height = 240;
            writeinfo.yuvFormat = YuvFormat.YUV420_IYUV;
            yvh.setWriteContext(writePath, writeinfo);
            System.Drawing.Bitmap testframe = yvh.getFrame();
            System.Drawing.Bitmap[] frames = new System.Drawing.Bitmap[20];
            for (int i = 0; i < frames.Length; i++)
            {
                frames[i] = testframe;
            }
            yvh.writeFrames(4, frames);
            yvh.writeFrames(1000, frames); // is > totalFrames
            try
            {
                yvh.writeFrames(-1, frames);
                Assert.Fail("no exception thrown");
            }
            catch (Exception )
            {

            }
            try
            {
            yvh.writeFrames(3, new System.Drawing.Bitmap[3]);
            Assert.Fail("no exception thrown");
            }
            catch (Exception)
            {

            }
            try
            {
                File.Delete(writePath);
            }
            catch (Exception )
            {

            }
        }