31 lines
809 B
C#
31 lines
809 B
C#
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
|
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
|
using OpenCvSharp;
|
|
|
|
namespace Hawkeye.VisionBuilder.Workflow.Operations.Image;
|
|
|
|
[Category("Image")]
|
|
public class InvertOperation:BaseOperation
|
|
{
|
|
|
|
public InvertOperation()
|
|
{
|
|
CanHaveProcessingError = false;
|
|
}
|
|
|
|
protected override void InterpretInternal(Context context)
|
|
{
|
|
if (!CheckImageExists(context)) return;
|
|
|
|
|
|
var res = new Mat(context.ActiveImage.ImageData.Size(), context.ActiveImage.ImageData.Type(), Scalar.All(0));
|
|
Cv2.BitwiseNot(context.ActiveImage.ImageData, res);
|
|
context.ActiveImage = new HawkeyeImage()
|
|
{
|
|
ImageData = res
|
|
};
|
|
|
|
Status = $"Image inverted";
|
|
Result = true;
|
|
}
|
|
} |