修复注释乱码
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
// ============================================================================
|
||||
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
||||
// ��辣�? ContourProcessor.cs
|
||||
// 文件名: ContourProcessor.cs
|
||||
// 描述: 轮廓查找算子,用于检测和分析图像中的轮廓
|
||||
// 功能:
|
||||
// - 璉�瘚见㦛�譍葉����刻蔭撱?
|
||||
// - 检测图像中的外部轮廓
|
||||
// - 根据面积范围过滤轮廓
|
||||
// - 霈∠�頧桀����雿閧鸌敺���Y妖��𪂹�踴��葉敹�����亦畆敶Y�嚗?
|
||||
// - 颲枏枂頧桀�靽⊥�靘𥕦�蝏剖���蝙�?
|
||||
// 蝞埈�: �箔�OpenCV��蔭撱𤘪�瘚讠�瘜?
|
||||
// 雿𡏭�? �𦒘� wei.lw.li@hexagon.com
|
||||
// - 计算轮廓的几何特征(面积、周长、中心、外接矩形等)
|
||||
// - 输出轮廓信息供后续处理使用
|
||||
// 算法: 基于OpenCV的轮廓检测算法
|
||||
// 作者: 李伟 wei.lw.li@hexagon.com
|
||||
// ============================================================================
|
||||
|
||||
using Emgu.CV;
|
||||
using Emgu.CV.CvEnum;
|
||||
using Emgu.CV.Structure;
|
||||
using Emgu.CV.Util;
|
||||
using XP.ImageProcessing.Core;
|
||||
using Serilog;
|
||||
using System.Drawing;
|
||||
using XP.ImageProcessing.Core;
|
||||
|
||||
namespace XP.ImageProcessing.Processors;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class ContourProcessor : ImageProcessorBase
|
||||
|
||||
OutputData.Clear();
|
||||
|
||||
// �𥕦遣颲枏��曉�����祉鍂鈭𤾸��?
|
||||
// 创建输入图像的副本用于处理
|
||||
Image<Gray, byte> processImage = inputImage.Clone();
|
||||
|
||||
// 步骤1:如果启用阈值分割,先进行二值化
|
||||
@@ -128,18 +128,18 @@ public class ContourProcessor : ImageProcessorBase
|
||||
|
||||
if (useOtsu)
|
||||
{
|
||||
// 雿輻鍂Otsu�芸𢆡���?
|
||||
// 使用Otsu自动阈值
|
||||
CvInvoke.Threshold(processImage, thresholdImage, 0, 255, ThresholdType.Otsu);
|
||||
_logger.Debug("Applied Otsu threshold");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 雿輻鍂�箏����?
|
||||
// 使用固定阈值
|
||||
CvInvoke.Threshold(processImage, thresholdImage, thresholdValue, 255, ThresholdType.Binary);
|
||||
_logger.Debug("Applied binary threshold with value {ThresholdValue}", thresholdValue);
|
||||
}
|
||||
|
||||
// 靽嘥����澆������㦛�讐鍂鈭舘�霂?
|
||||
// 保存阈值处理后的图像用于调试
|
||||
try
|
||||
{
|
||||
string debugPath = Path.Combine("logs", $"contour_threshold_{DateTime.Now:yyyyMMdd_HHmmss}.png");
|
||||
@@ -156,7 +156,7 @@ public class ContourProcessor : ImageProcessorBase
|
||||
processImage = thresholdImage;
|
||||
}
|
||||
|
||||
// 甇仿炊2嚗𡁜��𦦵𤌍��糓暺𤏸𠧧�箏�嚗屸�閬��頧砍㦛�?
|
||||
// 步骤2:如果目标是黑色区域,需要反转图像
|
||||
bool isBlackTarget = targetColor != null &&
|
||||
(targetColor.Equals("Black", StringComparison.OrdinalIgnoreCase) ||
|
||||
targetColor.Equals("黑色", StringComparison.OrdinalIgnoreCase));
|
||||
@@ -180,7 +180,7 @@ public class ContourProcessor : ImageProcessorBase
|
||||
}
|
||||
}
|
||||
|
||||
// 甇仿炊3嚗𡁏䰻�曇蔭撱?
|
||||
// 步骤3:查找轮廓
|
||||
using (VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint())
|
||||
{
|
||||
Mat hierarchy = new Mat();
|
||||
|
||||
Reference in New Issue
Block a user