Skip to content

Commit

Permalink
优化折线图外观,解决Fit文件读取问题
Browse files Browse the repository at this point in the history
  • Loading branch information
GarthTB committed Dec 8, 2024
1 parent e68071c commit 75b0660
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions LightCurve/Core/Tools/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
9 changes: 5 additions & 4 deletions LightCurve/Core/VidAna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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)
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- 每一组照片或一个视频文件进行一次统计。照片和视频不能混合处理。
- 选择输出位置时的文件名不是最终的文件名。最终的文件根据原文件来命名。
- 此程序不使用GPU。在统计大文件时可能卡顿。
- 折线图的高度固定为2000像素,宽度在800至4800之间浮动
- 折线图的高度固定为2000像素,宽度在2000至4800之间浮动

## 快捷键

Expand Down

0 comments on commit 75b0660

Please # to comment.