添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using SemiconductorVisionAlgorithm.SemiParams;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MainShell.AlgorithmCalib.Service
|
||||
{
|
||||
public static class MotionCalibFileService
|
||||
{
|
||||
public static void SaveCalibPointsFile(string path, List<Point> real, List<Point> ruler)
|
||||
{
|
||||
using (var sw = new StreamWriter(path))
|
||||
{
|
||||
sw.WriteLine("# realX, realY, rulerX, rulerY");
|
||||
int count = Math.Max(real.Count, ruler.Count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var r = i < real.Count ? real[i] : new Point(0, 0);
|
||||
var u = i < ruler.Count ? ruler[i] : new Point(0, 0);
|
||||
sw.WriteLine($"{r.X},{r.Y},{u.X},{u.Y}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadCalibPointsFile(string path, out List<Point> real, out List<Point> ruler)
|
||||
{
|
||||
real = new List<Point>();
|
||||
ruler = new List<Point>();
|
||||
|
||||
if (!File.Exists(path))
|
||||
return;
|
||||
|
||||
foreach (var line in File.ReadLines(path))
|
||||
{
|
||||
var l = line.Trim();
|
||||
if (string.IsNullOrEmpty(l)) continue;
|
||||
if (l.StartsWith("#")) continue;
|
||||
|
||||
var sp = l.Split(',');
|
||||
if (sp.Length < 4) continue;
|
||||
|
||||
real.Add(new Point(
|
||||
double.Parse(sp[0]),
|
||||
double.Parse(sp[1])
|
||||
));
|
||||
ruler.Add(new Point(
|
||||
double.Parse(sp[2]),
|
||||
double.Parse(sp[3])
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user