62 lines
1.3 KiB
C#
62 lines
1.3 KiB
C#
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
|
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
|
using OpenCvSharp;
|
|
|
|
namespace Hawkeye.VisionBuilder.Workflow.Operations.Morphology;
|
|
|
|
[Category("Morphology")]
|
|
public class UnionOperation : BaseOperation
|
|
{
|
|
public string SlotName { get; set; } = "Image";
|
|
|
|
public UnionOperation()
|
|
{
|
|
CanHaveProcessingError = false;
|
|
}
|
|
|
|
protected override void InterpretInternal(Context context)
|
|
{
|
|
if (!CheckImageExists(context)) return;
|
|
if (!CheckGrayscale(context)) return;
|
|
|
|
if (!context.Memory.ContainsKey(SlotName))
|
|
{
|
|
Status = "Slot not found";
|
|
Result = false;
|
|
return;
|
|
}
|
|
|
|
var first = context.ActiveImage;
|
|
var second = context.Memory[SlotName];
|
|
|
|
context.ActiveImage = new HawkeyeImage()
|
|
{
|
|
ImageData = first.ImageData.BitwiseOr(second.ImageData)
|
|
};
|
|
|
|
|
|
|
|
Result = true;
|
|
}
|
|
|
|
public override void Save(BinaryWriter bw)
|
|
{
|
|
base.Save(bw);
|
|
}
|
|
|
|
public override void Load(BinaryReader br)
|
|
{
|
|
base.Load(br);
|
|
}
|
|
|
|
public override void Save(Dictionary<string, object> dict)
|
|
{
|
|
base.Save(dict);
|
|
}
|
|
|
|
public override void Load(Dictionary<string, object> dict)
|
|
{
|
|
base.Load(dict);
|
|
}
|
|
}
|