67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
// ============================================================================
|
|
// Copyright © 2026 Hexagon Technology Center GmbH. All Rights Reserved.
|
|
// 文件� MirrorProcessor.cs
|
|
// æ��è¿°: 镜åƒ�ç®—å�,用于图åƒ�ç¿»è½?
|
|
// 功能:
|
|
// - 水平镜�(左�翻转)
|
|
// - 垂直镜�(上下翻转)
|
|
// - 对角镜åƒ�(水å¹?åž‚ç›´ç¿»è½¬ï¼Œç‰æ•?80°旋转ï¼?
|
|
// 算法: åƒ�ç´ å��æ ‡æ˜ å°„
|
|
// 作� �伟 wei.lw.li@hexagon.com
|
|
// ============================================================================
|
|
|
|
using Emgu.CV;
|
|
using Emgu.CV.CvEnum;
|
|
using Emgu.CV.Structure;
|
|
using Serilog;
|
|
using XP.ImageProcessing.Core;
|
|
|
|
namespace XP.ImageProcessing.Processors;
|
|
|
|
/// <summary>
|
|
/// 镜åƒ�ç®—å�
|
|
/// </summary>
|
|
public class MirrorProcessor : ImageProcessorBase
|
|
{
|
|
private static readonly ILogger _logger = Log.ForContext<MirrorProcessor>();
|
|
|
|
public MirrorProcessor()
|
|
{
|
|
Name = LocalizationHelper.GetString("MirrorProcessor_Name");
|
|
Description = LocalizationHelper.GetString("MirrorProcessor_Description");
|
|
}
|
|
|
|
protected override void InitializeParameters()
|
|
{
|
|
Parameters.Add("Direction", new ProcessorParameter(
|
|
"Direction",
|
|
LocalizationHelper.GetString("MirrorProcessor_Direction"),
|
|
typeof(string),
|
|
"Horizontal",
|
|
null,
|
|
null,
|
|
LocalizationHelper.GetString("MirrorProcessor_Direction_Desc"),
|
|
new string[] { "Horizontal", "Vertical", "Both" }));
|
|
|
|
_logger.Debug("InitializeParameters");
|
|
}
|
|
|
|
public override Image<Gray, byte> Process(Image<Gray, byte> inputImage)
|
|
{
|
|
string direction = GetParameter<string>("Direction");
|
|
|
|
var result = inputImage.Clone();
|
|
|
|
FlipType flipType = direction switch
|
|
{
|
|
"Vertical" => FlipType.Vertical,
|
|
"Both" => FlipType.Both,
|
|
_ => FlipType.Horizontal
|
|
};
|
|
|
|
CvInvoke.Flip(inputImage, result, flipType);
|
|
|
|
_logger.Debug("Process: Direction = {Direction}", direction);
|
|
return result;
|
|
}
|
|
} |