using Hawkeye.VisionBuilder.Workflow.Datatypes; using Hawkeye.VisionBuilder.Workflow.Operations.Attributes; using OpenCvSharp; namespace Hawkeye.VisionBuilder.Workflow.Operations.Image; [Category("Image")] public class ToGrayscaleOperation : BaseOperation { public ToGrayscaleOperation() { CanHaveProcessingError = false; } public HawkeyeImage? Image { get; set; } protected override void InterpretInternal(Context context) { if (!CheckImageExists(context)) return; if (!CheckColorful(context)) return; context.ActiveImage = new HawkeyeImage() { ImageData = context.ActiveImage.ImageData.CvtColor(ColorConversionCodes.BGR2GRAY) }; Status = "Convert image to grayscale"; Result = true; Image = context.ActiveImage; } }