using OpenCvSharp; namespace PLCSharp.VVMs.Vision.VisionFlowHandler.Processing { /// /// 拆分通道Handler /// public class SplitChannelHandler : IVisionFlowHandler { /// /// 类型 /// public VisionFlowType Type => VisionFlowType.取通道; /// /// 执行 /// /// 视觉功能 /// 变量项 /// 返回布尔值 public bool Execute(VisionFunction func, VisionFlow item) { if (func.Src.Channels() == 3) { if (item.IntParams.TryGetValue("ChannelIndex", out int _channelIndex)) { Mat[] channels = Cv2.Split(func.Src); func.Src = channels[_channelIndex]; } } return true; } } }