删除无用代码
This commit is contained in:
@@ -11,36 +11,15 @@ namespace 头罩视野.Services
|
||||
|
||||
|
||||
// 设备固定参数
|
||||
private static double R = 330; // 半球半径
|
||||
private static double angleStep = 10; // 每格角度
|
||||
public static double R = 330; // 半球半径
|
||||
public static double angleStep = 10; // 每格角度
|
||||
|
||||
// 定义参数(和你代码里一致)
|
||||
private const int totalLights = 81;
|
||||
//public const double standardArea = 140;
|
||||
public const int totalLights = 81;
|
||||
|
||||
/// <summary>有效亮度阈值:区分有效视野和噪声/遮挡的门槛设备标定经验值,≥12判定为有效视野</summary>
|
||||
public const int threshold = 12;
|
||||
///// <summary>双目标准标定总面积:无面罩空标准头模的双目总实测面积国标总视野保存率计算的基准值,单位:cm²</summary>
|
||||
//public const double StandardTotal = 10360;
|
||||
|
||||
/// <summary>异常值差值阈值:过滤孤立尖峰噪声当前点与前后点差值均>30时,判定为异常值并插值修正</summary>
|
||||
public const int OutlierDiffThreshold = 30;
|
||||
|
||||
/// <summary>灯条通道总数:360°圆周采样点数量对应每点5°(360° ÷ 72 = 5°/点),符合国标GB2890-2022要求</summary>
|
||||
public const int lightNum = 72;
|
||||
|
||||
/// <summary>设备最大检测半径:理论上的最大视野半径单位:mm,用来计算理论圆面积</summary> 这个是我们自己的设备值
|
||||
public const int maxRadius_mm = 330;
|
||||
|
||||
/// <summary>单眼标准标定面积:无面罩空标准头模的单眼实测面积 国标视野保存率计算的基准值,单位:cm²</summary>
|
||||
public const double standardArea = 5180;
|
||||
|
||||
/// <summary>双目标准标定总面积:无面罩空标准头模的双目总实测面积国标总视野保存率计算的基准值,单位:cm²</summary>
|
||||
public const double StandardTotal = 10360;
|
||||
|
||||
// 补充:用半径计算的单眼理论圆面积(供参考) 公式:π × 半径²,单位:cm²
|
||||
public static readonly double standardAreaOus = Math.PI * maxRadius_mm * maxRadius_mm / 100;
|
||||
|
||||
//双目重叠标准
|
||||
public static double StandardBinocular = 4150;
|
||||
|
||||
//空白视野面积计算
|
||||
public static readonly double _standardTotalArea = 2 * Math.PI * 330 * 330;
|
||||
@@ -51,9 +30,8 @@ namespace 头罩视野.Services
|
||||
return _standardTotalArea - binocularTotalArea;
|
||||
}
|
||||
|
||||
//下方视野
|
||||
// 固定参数:每一格灯代表 10 度(你的设备标准)
|
||||
|
||||
//下方视野 下方视野角度 = 人眼到「最低亮灯条」的夹角
|
||||
|
||||
/// <summary>
|
||||
/// 计算 下方视野角度(单位:度 °)
|
||||
/// </summary>
|
||||
@@ -71,7 +49,6 @@ namespace 头罩视野.Services
|
||||
angles.Add(angle);
|
||||
}
|
||||
}
|
||||
|
||||
// 没有亮灯返回 0
|
||||
if (angles.Count == 0)
|
||||
return 0;
|
||||
@@ -85,7 +62,7 @@ namespace 头罩视野.Services
|
||||
{
|
||||
|
||||
// 1. 总视野保存率
|
||||
double ratioTotal = binocularRate / StandardTotal;
|
||||
double ratioTotal = binocularRate / _standardTotalArea;
|
||||
double gammaTotal = GetVisionGamma(ratioTotal);
|
||||
double totalRate = gammaTotal * ratioTotal * 100;
|
||||
return (totalRate);
|
||||
@@ -124,7 +101,7 @@ namespace 头罩视野.Services
|
||||
|
||||
|
||||
|
||||
// 传入:72个灯的亮灭数据(0=灭,1=亮)
|
||||
// 传入:81个灯的亮灭数据(0=灭,1=亮)
|
||||
// 返回:椭圆面积
|
||||
public static double CalculateEllipseArea(int[] lightData, List<(int m, int n)> lightPositions)
|
||||
{
|
||||
|
||||
@@ -191,6 +191,11 @@ namespace 头罩视野.Views
|
||||
|
||||
// 1. 读取输入框
|
||||
double stepAngle = double.Parse(fbspeed.Text); // 分辨角度 例:10
|
||||
if (double.TryParse(fbspeed.Text, out double step))
|
||||
{
|
||||
// 直接赋值给计算页面的静态变量
|
||||
GetArea.angleStep = step;
|
||||
}
|
||||
//double speed = double.Parse(zdangle.Text); // 转动速度
|
||||
int[] lightData = DataList.Cast<int>().ToArray(); // 1. 把DataList(List<dynamic>)转成方法需要的int[]
|
||||
// 1. 定义总和变量,初始为0
|
||||
@@ -205,10 +210,15 @@ namespace 头罩视野.Views
|
||||
//2. 调用CalculateEllipseArea,传入两个参数
|
||||
double area = GetArea.CalculateEllipseArea(lightData, _lightPositions);
|
||||
totalArea += area;
|
||||
//double bottomViewAngle = GetArea.CalculateBottomViewAngle(lightData, _lightPositions);
|
||||
//totalBottomViewAngle += bottomViewAngle;
|
||||
double bottomViewAngle = GetArea.CalculateBottomViewAngle(lightData, _lightPositions);
|
||||
totalBottomViewAngle += bottomViewAngle;
|
||||
}
|
||||
UpdateVisionResults(totalArea, totalBottomViewAngle);
|
||||
isFinished = _modbusMaster.ReadCoils(1, 102, 1)[0];
|
||||
if (isFinished)
|
||||
{
|
||||
Button_Click_Stop(null, null);
|
||||
UpdateVisionResults(totalArea, totalBottomViewAngle);
|
||||
}
|
||||
}
|
||||
//页面渲染值
|
||||
|
||||
@@ -236,8 +246,8 @@ namespace 头罩视野.Views
|
||||
}
|
||||
|
||||
//// 4. 计算下方视野面积
|
||||
//int botViAnInt = (int)Math.Round(BotViAn);
|
||||
//xfsyarea.Text = botViAnInt.ToString("0.0"); // 下方视野
|
||||
int botViAnInt = (int)Math.Round(BotViAn);
|
||||
xfsyarea.Text = botViAnInt.ToString("0.0"); // 下方视野
|
||||
|
||||
// 5. 计算视野保存率(双目)
|
||||
if (double.TryParse(smsyarea.Text, out double totalAreaForRate))
|
||||
|
||||
Reference in New Issue
Block a user