Example #1
0
        private void LoadFiles()
        {
            this.Invoke(new Action(() =>
            {
                splitContainer3.Enabled = false;
                CloseFiles();
                timerLoading.Start();
                labelLoading.Visible = true;
            }));

            _csvProcessor          = new StatisticsProcessor(_filenames, _frameOffset);
            _csvProcessor.Settings = Settings.Current.DetectionSettings;
            _csvProcessor.Log     += new Action <string>(_csvProcessor_Log);
            _csvProcessor.Process();

            LoadSettings();

            _videoFile                = new MediaFile();
            _videoFile.Resolution     = MediaFile.ResolutionOption.Full;
            _videoFile.OutputYData    = true;
            _videoFile.OutputRGBImage = true;
            //_videoFile.OutputYImage = true;
            _videoFile.Open(_filenames.videoFilename);

            var frameField = _videoFile.GetVideoFrameField(_currentFieldIndex);

            //if (frameField.Image != null)
            //    frameField.Image.Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);

            this.Invoke(new Action(() =>
            {
                timerLoading.Stop();
                labelLoading.Visible = false;

                objectListViewBlocks.SetObjects(_csvProcessor.Data.Blocks);
                UpdateButtons();

                timelineUserControl1.StatisticsProcessor = _csvProcessor;
                timelineUserControl1.TotalFields         = _videoFile.TotalFields;
                timelineUserControl1.FieldsPerSecond     = _videoFile.FieldsPerSecond;

                var graphsVideoFile                    = _videoFile.Clone(MediaFile.ResolutionOption.Full);
                graphsVideoFile.OutputYImage           = false;
                graphsVideoFile.OutputRGBImage         = true;
                graphsUserControl1.StatisticsProcessor = _csvProcessor;
                graphsUserControl1.VideoMediaFile      = graphsVideoFile;
                graphsUserControl1.SetDirty();

                timelineUserControl1.SecondsVisible = graphsUserControl1.SecondsVisible;

                SetPreviewField(frameField);

                splitContainer3.Enabled = true;
            }));
        }
Example #2
0
        public MediaFile Clone(ResolutionOption resolution)
        {
            var clone = new MediaFile();

            clone.Resolution       = resolution;
            clone.OutputRGBImage   = OutputRGBImage;
            clone.OutputYData      = OutputYData;
            clone.OutputYImage     = OutputYImage;
            clone._lastFieldNumber = _lastFieldNumber;
            clone.Open(_filename);
            return(clone);
        }
Example #3
0
        private static int ShowWindow(string inputName, string videoFilename, string audioFilename, int frameOffset)
        {
            if (true)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var form = new MainForm(inputName, videoFilename, audioFilename, frameOffset);
                Application.Run(form);
            }
            else
            {
                var _filenames = FileDetect.FillFilenames(inputName, videoFilename, audioFilename);

                var _videoFile = new MediaFile();
                _videoFile.Resolution     = MediaFile.ResolutionOption.Full;
                _videoFile.OutputRGBImage = false;
                _videoFile.OutputYData    = true;
                _videoFile.OutputYImage   = false;
                _videoFile.Open(_filenames.videoFilename);

                int lastPrintSeconds = 0;

                int frameCount = 0;
                var stopwatch  = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                for (int fieldNumber = 0; fieldNumber < _videoFile.TotalFields; fieldNumber++)
                //for (int fieldNumber = 0; fieldNumber < 1000; fieldNumber++)
                {
                    var frameField = _videoFile.GetVideoFrameField(fieldNumber, MediaFile.SeekModes.Accurate);
                    //frameField.YData.GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);
                    frameField.Dispose();

                    long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
                    int  elapsedSeconds      = (int)(elapsedMilliseconds / 1000);
                    if (elapsedSeconds != lastPrintSeconds)
                    {
                        lastPrintSeconds = elapsedSeconds;
                        var fps = frameCount * 1000.0f / (float)stopwatch.ElapsedMilliseconds;
                        Console.WriteLine("Frame: " + frameCount.ToString() + "  FPS: " + fps.ToString("0.00"));
                    }

                    frameCount++;
                }

                //for (int fieldNumber = 500; fieldNumber < 504; fieldNumber++)
                //{
                //    var frameField = _videoFile.GetVideoFrameField(fieldNumber, MediaFile.SeekModes.Accurate);
                //    //frameField.Image.Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);
                //    //frameField.YData.GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);
                //    frameField.YData.GetFloatData().GetBitmap().Save(@"D:\temp\image-" + frameField.FieldNumber.ToString("00000") + ".png", System.Drawing.Imaging.ImageFormat.Png);

                //    var yData = frameField.YData;
                //    var floatData = frameField.YData.GetFloatData();

                //    stopwatch.Restart();
                //    for (int test = 0; test < 1000; test++)
                //    {
                //        //var image = floatData.GetBitmap();
                //        var image = yData.GetBitmap();

                //        image = null;
                //        //GC.Collect();
                //    }
                //    Console.WriteLine("Elapsed: " + stopwatch.Elapsed.ToString());

                //    frameField.Dispose();
                //}
            }

            return(0);
        }