Пример #1
0
        public MotionData AnalizeAll(Parameters para)
        {
            string     targetDir = Settings.TargetDir(para.VideoFile);
            MotionData md        = new MotionData();

            Action <object, DoWorkEventArgs> ProgressDialogDoWork = (sender, e) => {
                using (VideoWriter writer = new VideoWriter(Settings.DetectVideoname(para.VideoFile),
                                                            FourCC.MPG4, 30, output3.Size())) {
                    var bw  = sender as BackgroundWorker;
                    int num = para.EndFrame - para.StartFrame + 1;
                    for (int t = para.StartFrame; t < para.EndFrame; t++)
                    {
                        PosFrames = t;
                        var contour = GetContour(para);
                        if (contour != null)
                        {
                            TXYW txyw = DrawToOutput(contour, para);
                            md.AddRawData(txyw);
                        }
                        writer.Write(output3);
                        if (bw.CancellationPending)
                        {
                            e.Cancel = true;
                            break;
                        }
                        string message = string.Format("{0}/{1}", t - para.StartFrame, num);
                        bw.ReportProgress((int)((t - para.StartFrame) * 100 / num), message);
                    }
                    if (!e.Cancel)
                    {
                        md.UpdatePlotData();
                    }
                    writer.Release();
                }
            };

            ProgressDialog pd     = new ProgressDialog($"解析中:{para.VideoFile}", new DoWorkEventHandler(ProgressDialogDoWork));
            DialogResult   result = pd.ShowDialog();

            return(result == DialogResult.OK ? md : null);
        }
Пример #2
0
        public static MotionData TryLoadRawData(string videoFile, Parameters parameters)
        {
            string file = Settings.RawDataname(videoFile);

            if (File.Exists(file))
            {
                MotionData md = new MotionData();
                md.parameters = parameters;
                using (var sr = new StreamReader(file)) {
                    sr.ReadLine();
                    while (!sr.EndOfStream)
                    {
                        md.AddRawData(TXYW.FromStr(sr.ReadLine()));
                    }
                }
                return(md);
            }
            else
            {
                return(null);
            }
        }