check point
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
||||
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.Workflow.Operations.Basic;
|
||||
|
||||
[Category("Basic")]
|
||||
public class ThresholdOperation:BaseOperation
|
||||
{
|
||||
|
||||
public ScriptValue ThresholdMin { get; set; } = new ScriptValue(){Script = "128"};
|
||||
|
||||
public ThresholdOperation()
|
||||
{
|
||||
CanHaveProcessingError = false;
|
||||
}
|
||||
|
||||
protected override void InterpretInternal(Context context)
|
||||
{
|
||||
if (!CheckImageExists(context)) return;
|
||||
|
||||
if(!CheckGrayscale(context))return;
|
||||
|
||||
context.ActiveImage = new HawkeyeImage()
|
||||
{
|
||||
ImageData = context.ActiveImage.ImageData.Threshold(GetScriptValue<float>(ThresholdMin), 255,ThresholdTypes.Binary)
|
||||
};
|
||||
Result = true;
|
||||
}
|
||||
|
||||
public override void Save(BinaryWriter bw)
|
||||
{
|
||||
base.Save(bw);
|
||||
bw.Write(ThresholdMin.Script);
|
||||
|
||||
}
|
||||
|
||||
public override void Load(BinaryReader br)
|
||||
{
|
||||
base.Load(br);
|
||||
ThresholdMin.Script = br.ReadString();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user