规范类名及命名空间名称

This commit is contained in:
李伟
2026-04-13 14:35:37 +08:00
parent c430ec229b
commit ace1c70ddf
217 changed files with 1271 additions and 1384 deletions
@@ -0,0 +1,133 @@
// ============================================================================
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
// 文件å? FillRateProcessor.cs
// æè¿°: 通孔填锡率测é‡ç®—å­ï¼ˆå€¾æ–œæŠ•影几何法),基于四椭圆ROI
// 功能:
// - æ ·å“倾斜çº?5°放置,利用投影ä½ç§»å…³ç³»è®¡ç®—填锡率
// - 四个椭圆定义�
// E1 = 通孔底部轮廓
// E2 = 通孔顶部轮廓
// E3 = 填锡起点(与E1é‡åˆï¼Œä»£è¡?%填锡ï¼?
// E4 = 填锡终点(锡实际填充到的高度�
// - 填锡�= |E4中心 - E3中心| / |E2中心 - E1中心| × 100%
// - 纯几何方法,ä¸ä¾èµ–ç°åº¦åˆ†æž?
// - IPC-610 THT 分级判定(Class 1/2/3�
// 算法: 倾斜投影ä½ç§»æ¯”例
// 作è€? æŽä¼Ÿ wei.lw.li@hexagon.com
// ============================================================================
using Emgu.CV;
using Emgu.CV.Structure;
using Serilog;
using System.Drawing;
using XP.ImageProcessing.Core;
namespace XP.ImageProcessing.Processors;
/// <summary>
/// 通孔填锡率测é‡ç®—å­ï¼ˆå€¾æ–œæŠ•影几何法)
/// </summary>
public class FillRateProcessor : ImageProcessorBase
{
private static readonly ILogger _logger = Log.ForContext<FillRateProcessor>();
public FillRateProcessor()
{
Name = LocalizationHelper.GetString("FillRateProcessor_Name");
Description = LocalizationHelper.GetString("FillRateProcessor_Description");
}
protected override void InitializeParameters()
{
// 四个椭圆(由交互控件注入,UIä¸å¯è§ï¼‰
AddEllipseParams("E1", 200, 250, 60, 50, 0); // 底部
AddEllipseParams("E2", 220, 180, 60, 50, 0); // 顶部
AddEllipseParams("E3", 200, 250, 60, 50, 0); // 填锡起点�E1�
AddEllipseParams("E4", 210, 220, 55, 45, 0); // 填锡终点
Parameters.Add("THTLimit", new ProcessorParameter(
"THTLimit",
LocalizationHelper.GetString("FillRateProcessor_THTLimit"),
typeof(double), 75.0, 0.0, 100.0,
LocalizationHelper.GetString("FillRateProcessor_THTLimit_Desc")));
Parameters.Add("Thickness", new ProcessorParameter(
"Thickness",
LocalizationHelper.GetString("FillRateProcessor_Thickness"),
typeof(int), 2, 1, 10,
LocalizationHelper.GetString("FillRateProcessor_Thickness_Desc")));
}
private void AddEllipseParams(string prefix, int cx, int cy, double a, double b, double angle)
{
Parameters.Add($"{prefix}_CX", new ProcessorParameter($"{prefix}_CX", $"{prefix}_CX", typeof(int), cx, null, null, "") { IsVisible = false });
Parameters.Add($"{prefix}_CY", new ProcessorParameter($"{prefix}_CY", $"{prefix}_CY", typeof(int), cy, null, null, "") { IsVisible = false });
Parameters.Add($"{prefix}_A", new ProcessorParameter($"{prefix}_A", $"{prefix}_A", typeof(double), a, null, null, "") { IsVisible = false });
Parameters.Add($"{prefix}_B", new ProcessorParameter($"{prefix}_B", $"{prefix}_B", typeof(double), b, null, null, "") { IsVisible = false });
Parameters.Add($"{prefix}_Angle", new ProcessorParameter($"{prefix}_Angle", $"{prefix}_Angle", typeof(double), angle, null, null, "") { IsVisible = false });
}
public override Image<Gray, byte> Process(Image<Gray, byte> inputImage)
{
double thtLimit = GetParameter<double>("THTLimit");
int thickness = GetParameter<int>("Thickness");
// 获å–四个椭圆中心
int e1cx = GetParameter<int>("E1_CX"), e1cy = GetParameter<int>("E1_CY");
int e2cx = GetParameter<int>("E2_CX"), e2cy = GetParameter<int>("E2_CY");
int e3cx = GetParameter<int>("E3_CX"), e3cy = GetParameter<int>("E3_CY");
int e4cx = GetParameter<int>("E4_CX"), e4cy = GetParameter<int>("E4_CY");
// èŽ·å–æ¤­åœ†è½´å‚数(用于绘制ï¼?
double e1a = GetParameter<double>("E1_A"), e1b = GetParameter<double>("E1_B"), e1ang = GetParameter<double>("E1_Angle");
double e2a = GetParameter<double>("E2_A"), e2b = GetParameter<double>("E2_B"), e2ang = GetParameter<double>("E2_Angle");
double e3a = GetParameter<double>("E3_A"), e3b = GetParameter<double>("E3_B"), e3ang = GetParameter<double>("E3_Angle");
double e4a = GetParameter<double>("E4_A"), e4b = GetParameter<double>("E4_B"), e4ang = GetParameter<double>("E4_Angle");
_logger.Debug("FillRate: E1=({E1X},{E1Y}), E2=({E2X},{E2Y}), E3=({E3X},{E3Y}), E4=({E4X},{E4Y})",
e1cx, e1cy, e2cx, e2cy, e3cx, e3cy, e4cx, e4cy);
OutputData.Clear();
// 计算通孔全高度的投影ä½ç§»ï¼ˆE1底部 â†?E2顶部ï¼?
double fullDx = e2cx - e1cx;
double fullDy = e2cy - e1cy;
double fullDistance = Math.Sqrt(fullDx * fullDx + fullDy * fullDy);
// 计算填锡高度的投影ä½ç§»ï¼ˆE3起点 â†?E4终点ï¼?
double fillDx = e4cx - e3cx;
double fillDy = e4cy - e3cy;
double fillDistance = Math.Sqrt(fillDx * fillDx + fillDy * fillDy);
// 填锡çŽ?= 填锡ä½ç§» / 全高度ä½ç§?
double fillRate = fullDistance > 0 ? (fillDistance / fullDistance) * 100.0 : 0;
fillRate = Math.Clamp(fillRate, 0, 100);
// 判定
string classification = fillRate >= thtLimit ? "PASS" : "FAIL";
// 存储结果
OutputData["FillRateResult"] = true;
OutputData["FillRate"] = fillRate;
OutputData["VoidRate"] = 100.0 - fillRate;
OutputData["FullDistance"] = fullDistance;
OutputData["FillDistance"] = fillDistance;
OutputData["THTLimit"] = thtLimit;
OutputData["Classification"] = classification;
OutputData["Thickness"] = thickness;
// 椭圆几何(用于绘制)
OutputData["E1"] = (new Point(e1cx, e1cy), new Size((int)e1a, (int)e1b), e1ang);
OutputData["E2"] = (new Point(e2cx, e2cy), new Size((int)e2a, (int)e2b), e2ang);
OutputData["E3"] = (new Point(e3cx, e3cy), new Size((int)e3a, (int)e3b), e3ang);
OutputData["E4"] = (new Point(e4cx, e4cy), new Size((int)e4a, (int)e4b), e4ang);
string resultText = $"{fillRate:F1}% | {classification}";
OutputData["ResultText"] = resultText;
_logger.Information("FillRate (geometric): {Rate}%, {Class}, FullDist={FD:F1}, FillDist={FiD:F1}",
fillRate, classification, fullDistance, fillDistance);
return inputImage.Clone();
}
}