提交
This commit is contained in:
@ -136,9 +136,8 @@ namespace DH.Devices.Vision
|
||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||
//
|
||||
Console.WriteLine("检测结果JSON:" + json);
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
if (detResult == null)
|
||||
{
|
||||
return;
|
||||
@ -176,7 +175,6 @@ namespace DH.Devices.Vision
|
||||
MLResult mlResult = new MLResult();
|
||||
Mat originMat=new Mat() ;
|
||||
Mat detectMat= new Mat();
|
||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
||||
try
|
||||
{
|
||||
if (req.mImage == null)
|
||||
@ -266,18 +264,17 @@ namespace DH.Devices.Vision
|
||||
// 释放 Mat 资源
|
||||
if (detectMat != null)
|
||||
{
|
||||
detectMat.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
detectMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
}
|
||||
|
||||
if (originMat != null)
|
||||
{
|
||||
originMat.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
originMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,60 +206,47 @@ namespace DH.Devices.Vision
|
||||
{
|
||||
|
||||
|
||||
//当前检测项的 过滤条件
|
||||
//var conditionList = detectConfig.DetectionFilterList
|
||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
// .GroupBy(u => u.ResultState)
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
//当前检测项的 过滤条件
|
||||
//var conditionList = detectConfig.DetectionFilterList
|
||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
// .GroupBy(u => u.ResultState)
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
// 当前检测项的 过滤条件
|
||||
var conditionList = detectConfig.DetectionLableList
|
||||
.Where(u=>u.LabelName == d.LabelName)
|
||||
.GroupBy(u => u.ResultState)
|
||||
.OrderBy(u => u.Key)
|
||||
.ToList();
|
||||
|
||||
|
||||
//if (conditionList.Count == 0)
|
||||
//{
|
||||
if (conditionList.Count == 0)
|
||||
{
|
||||
|
||||
// d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||
// ? ResultState.OK
|
||||
// : ResultState.DetectNG;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// d.FinalResult = detectConfig.IsMixModel
|
||||
// ? ResultState.A_NG
|
||||
// : ResultState.OK;
|
||||
d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||
? ResultState.OK
|
||||
: ResultState.DetectNG;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.FinalResult = detectConfig.IsMixModel
|
||||
? ResultState.A_NG
|
||||
: ResultState.OK;
|
||||
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
//foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
//{
|
||||
// //bool b = group.ToList().Any(f =>
|
||||
// //{
|
||||
// // return f.FilterOperation(d);
|
||||
// //});
|
||||
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
{
|
||||
bool b = group.ToList().Any(f =>
|
||||
{
|
||||
return f.FilterOperation(d);
|
||||
});
|
||||
|
||||
|
||||
// //if (b)
|
||||
// //{
|
||||
// // d.FinalResult = group.Key;
|
||||
// // break;
|
||||
// //}
|
||||
if (b)
|
||||
{
|
||||
d.FinalResult = group.Key;
|
||||
break;
|
||||
}
|
||||
|
||||
// if (group.Any(f => f.FilterOperation(d)))
|
||||
// {
|
||||
// d.FinalResult = group.Key;
|
||||
// break;
|
||||
// }
|
||||
// //else
|
||||
// //{
|
||||
// // d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
// //}
|
||||
//}
|
||||
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
|
Reference in New Issue
Block a user