Exemple #1
0
 private void EnsureInputLoaded()
 {
     if (input == null)
     {
         input = YuvEncoder.Decode(Size.Width, Size.Height, FileName.Path, LogFileName.Path, MotionVectorFileName.Path);
     }
 }
Exemple #2
0
        public void TestVideoFunctionality()
        {
            int    width                = 352;
            int    height               = 240;
            string videoName            = @"..\..\..\..\resources\americanFootball_352x240_125.yuv";  // be sure to adjust this beforehand
            string logFileName          = @"..\..\..\..\resources\ModeGrid_AmFootball_OUR.dat";
            string motionVectorFileName = @"..\..\..\..\resources\motion_info\motion_info_football_qp20.csv";
            string saveName             = @"..\..\..\..\output\";

            // leave the file extension away
            YuvEncoder.Video video = YuvEncoder.Decode(width, height, videoName, logFileName, motionVectorFileName);
            // Don't expect this to work if the filename doesn't happen to be formatted
            // just the right way
            Assert.Equal(video.FrameCount, int.Parse(videoName.Substring(videoName.Length - 7, 3)));
            // Test video and frame indexer
            Assert.Equal(new Rgb(0, 0, 0), video[0].GetPixelOrBlack(-1, -1));
            // obviously, this is only true if the video is either very large and black or not that large
            Assert.Equal(new Rgb(0, 0, 0), video[0].GetPixelOrBlack(9999999, 9999999));
            Assert.Equal(video[0][0, 0], video[0].GetPixelOrBlack(0, 0));

            Bitmap bmp;

            // I test the first and last three frames
            for (int i = 0; i < 3; i++)
            {
                bmp = FrameToBitmap(video[i]);
                bmp.Save(saveName + i.ToString() + ".png");
            }
            for (int i = video.FrameCount - 4; i < video.FrameCount; i++)
            {
                bmp = FrameToBitmap(video[i]);
                bmp.Save(saveName + i.ToString() + ".png");
            }
        }