diff --git a/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.cs b/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.cs
index fa06c57..87a0cb7 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.cs
+++ b/PLCSharpWpf/VVMs/Vision/VisionConfigViewModel.cs
@@ -346,6 +346,9 @@ namespace PLCSharp.VVMs.Vision
newFlow.DoubleParams["ImageY"] = 0;
newFlow.StringParams["TransformMat"] = "";
break;
+ case VisionFlowType.图像翻转:
+ newFlow.IntParams["FlipDirection"] = 0;
+ break;
case VisionFlowType.ROI解码:
newFlow.IntParams["DecodeType"] = 0;
newFlow.BoolParams["EnableMirror"] = false;
@@ -580,6 +583,9 @@ namespace PLCSharp.VVMs.Vision
case VisionFlowType.坐标转换:
ContentRegion = new CoordTransform();
break;
+ case VisionFlowType.图像翻转:
+ ContentRegion = new ImageFlip();
+ break;
case VisionFlowType.ROI解码:
ContentRegion = new BarcodeDecode();
break;
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml
new file mode 100644
index 0000000..5917d63
--- /dev/null
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml.cs b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml.cs
new file mode 100644
index 0000000..eab30dc
--- /dev/null
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlip.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Processing
+{
+ ///
+ /// ImageFlip.xaml 的交互逻辑
+ ///
+ public partial class ImageFlip : UserControl
+ {
+ public ImageFlip()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlipHandler.cs b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlipHandler.cs
new file mode 100644
index 0000000..4e3bcd7
--- /dev/null
+++ b/PLCSharpWpf/VVMs/Vision/VisionFlowHandler/Processing/ImageFlipHandler.cs
@@ -0,0 +1,31 @@
+using OpenCvSharp;
+
+namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Processing
+{
+ ///
+ /// 图像翻转Handler — 对图像进行水平或垂直翻转
+ ///
+ public class ImageFlipHandler : IVisionFlowHandler
+ {
+ public VisionFlowType Type => VisionFlowType.图像翻转;
+
+ public bool Execute(VisionFunction func, VisionFlow item)
+ {
+ var src = func.Src ?? throw new Exception("请先获取图片!");
+
+ // 读取翻转方向:0=水平(左右),1=垂直(上下)
+ int direction = item.IntParams.TryGetValue("FlipDirection", out int dir) ? dir : 0;
+
+ FlipMode flipMode = direction switch
+ {
+ 0 => FlipMode.Y, // 水平翻转(左右)
+ 1 => FlipMode.X, // 垂直翻转(上下)
+ _ => FlipMode.Y,
+ };
+
+ Cv2.Flip(src, src, flipMode);
+
+ return true;
+ }
+ }
+}
diff --git a/PLCSharpWpf/VVMs/Vision/VisionFunction.cs b/PLCSharpWpf/VVMs/Vision/VisionFunction.cs
index ae2f226..d49cea9 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionFunction.cs
+++ b/PLCSharpWpf/VVMs/Vision/VisionFunction.cs
@@ -337,6 +337,7 @@ namespace PLCSharp.VVMs.Vision
[VisionFlowType.微信解码] = new WeChatDecodeHandler(),
[VisionFlowType.颜色面积] = new ColorAreaHandler(),
[VisionFlowType.灰度面积] = new GrayAreaHandler(),
+ [VisionFlowType.图像翻转] = new ImageFlipHandler(),
};
[NotMapped]
diff --git a/PLCSharpWpf/VVMs/Vision/VisionType.cs b/PLCSharpWpf/VVMs/Vision/VisionType.cs
index c0465aa..da93ae3 100644
--- a/PLCSharpWpf/VVMs/Vision/VisionType.cs
+++ b/PLCSharpWpf/VVMs/Vision/VisionType.cs
@@ -46,6 +46,8 @@
各通道最大值 = 16,
[FlowCategory("图像处理")]
阈值 = 17,
+ [FlowCategory("图像处理")]
+ 图像翻转 = 19,
[FlowCategory("图像处理")]
坐标转换 = 18,