diff --git a/LightCurve/Core/Tools/File.cs b/LightCurve/Core/Tools/File.cs index 36ca3d9..96ecfc5 100644 --- a/LightCurve/Core/Tools/File.cs +++ b/LightCurve/Core/Tools/File.cs @@ -129,12 +129,14 @@ private static void OutputPlot(double[] values, string dir, string name) plot.XLabel("Frame Number"); plot.YLabel("Value"); plot.ScaleFactor = 2; - if (values.Length > 1) - plot.Axes.SetLimits(1, indexes[^1], 0, 1); + + if (values.Length > 1) plot.Axes.SetLimits(1, indexes[^1], 0, 1); + else plot.Axes.SetLimits(0, 2, 0, 1); + plot.Axes.AntiAlias(true); var plotWidth = values.Length switch { - <= 80 => 800, + <= 200 => 2000, >= 480 => 4800, _ => values.Length * 10, }; diff --git a/LightCurve/Core/VidAna.cs b/LightCurve/Core/VidAna.cs index 05ae949..87d9ee9 100644 --- a/LightCurve/Core/VidAna.cs +++ b/LightCurve/Core/VidAna.cs @@ -22,18 +22,19 @@ internal void Run() try { using VideoCapture vid = new(file.FullName); - var values = new double[vid.FrameCount]; + var values = vid.FrameCount > 0 + ? new List(vid.FrameCount) : []; Mat frame = new(), roi = new(); - for (int i = 0; vid.Read(frame); i++) + while (vid.Read(frame)) { roi = ImgProc.GetROI(frame, x, y, w, h); - values[i] = ImgProc.GetValue(roi, channel); + values.Add(ImgProc.GetValue(roi, channel)); } var outName = Tools.File.GenOutName([file]); outName = ValCvt.AppendSuff(outName, channel); - Tools.File.OutputValues(outputType, values, outputDir, outName); + Tools.File.OutputValues(outputType, [.. values], outputDir, outName); } catch (Exception e) { diff --git a/README.md b/README.md index 9a0bbf2..1e2ac8b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ - 每一组照片或一个视频文件进行一次统计。照片和视频不能混合处理。 - 选择输出位置时的文件名不是最终的文件名。最终的文件根据原文件来命名。 - 此程序不使用GPU。在统计大文件时可能卡顿。 -- 折线图的高度固定为2000像素,宽度在800至4800之间浮动。 +- 折线图的高度固定为2000像素,宽度在2000至4800之间浮动。 ## 快捷键