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.Image;
|
||||
|
||||
[Category("Image")]
|
||||
public class ConvertOperation: BaseOperation
|
||||
{
|
||||
public enum EConversionType
|
||||
{
|
||||
RGBToHSV,
|
||||
HSVToRGB,
|
||||
}
|
||||
public ConvertOperation()
|
||||
{
|
||||
CanHaveProcessingError = false;
|
||||
}
|
||||
|
||||
public EConversionType ConversionType { get; set; }
|
||||
protected override void InterpretInternal(Context context)
|
||||
{
|
||||
if (!CheckImageExists(context)) return;
|
||||
var mat = context.ActiveImage.ImageData;
|
||||
Mat res;
|
||||
switch (ConversionType)
|
||||
{
|
||||
case EConversionType.RGBToHSV:
|
||||
res = mat.CvtColor(OpenCvSharp.ColorConversionCodes.BGR2HSV);
|
||||
break;
|
||||
case EConversionType.HSVToRGB:
|
||||
res = mat.CvtColor(OpenCvSharp.ColorConversionCodes.HSV2BGR);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
context.ActiveImage = new HawkeyeImage() { ImageData = res};
|
||||
Status = "";
|
||||
Result = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
||||
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.Workflow.Operations.Image;
|
||||
|
||||
[Category("Image")]
|
||||
public class GetChannelOperation: BaseOperation
|
||||
{
|
||||
public int Channel { get; set; }
|
||||
|
||||
public GetChannelOperation()
|
||||
{
|
||||
CanHaveProcessingError = false;
|
||||
}
|
||||
|
||||
protected override void InterpretInternal(Context context)
|
||||
{
|
||||
var channel = context.ActiveImage.ImageData.ExtractChannel(Channel);
|
||||
context.ActiveImage = new HawkeyeImage() {ImageData = channel};
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Get channel {Channel}";
|
||||
}
|
||||
|
||||
public override void Save(BinaryWriter bw)
|
||||
{
|
||||
base.Save(bw);
|
||||
bw.Write(Channel);
|
||||
}
|
||||
|
||||
public override void Load(BinaryReader br)
|
||||
{
|
||||
base.Load(br);
|
||||
Channel = br.ReadInt32();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
||||
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.Workflow.Operations.Image;
|
||||
|
||||
[Category("Image")]
|
||||
public class ImageSizeOperation : BaseOperation
|
||||
{
|
||||
|
||||
public ImageSizeOperation()
|
||||
{
|
||||
CanHaveProcessingError = false;
|
||||
}
|
||||
public int Width { get; set; } = 450;
|
||||
public int Height { get; set; } = 352;
|
||||
|
||||
protected override void InterpretInternal(Context context)
|
||||
{
|
||||
if (!CheckImageExists(context)) return;
|
||||
|
||||
context.ActiveImage = new HawkeyeImage()
|
||||
{
|
||||
ImageData = context.ActiveImage.ImageData.Resize(new OpenCvSharp.Size(Width, Height))
|
||||
};
|
||||
|
||||
Status = $"Image resized to {Width}x{Height}";
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Hawkeye.VisionBuilder.Workflow.Datatypes;
|
||||
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.Workflow.Operations.Image;
|
||||
|
||||
[Category("Image")]
|
||||
public class ImageSizeProportionOperation:BaseOperation
|
||||
{
|
||||
public ImageSizeProportionOperation()
|
||||
{
|
||||
CanHaveProcessingError = false;
|
||||
}
|
||||
|
||||
public double Width { get; set; } = 0.25;
|
||||
public double Height { get; set; } = 0.25;
|
||||
|
||||
protected override void InterpretInternal(Context context)
|
||||
{
|
||||
if (!CheckImageExists(context)) return;
|
||||
|
||||
context.ActiveImage = new HawkeyeImage()
|
||||
{
|
||||
ImageData = context.ActiveImage!.ImageData.Resize(Size.Zero, Width, Height)
|
||||
};
|
||||
|
||||
Status = $"Image resized to {context.ActiveImage.ImageData.Width}x{context.ActiveImage.ImageData.Height}";
|
||||
Result = true;
|
||||
}
|
||||
|
||||
public override void Save(BinaryWriter bw)
|
||||
{
|
||||
base.Save(bw);
|
||||
bw.Write(Width);
|
||||
bw.Write(Height);
|
||||
}
|
||||
|
||||
public override void Load(BinaryReader br)
|
||||
{
|
||||
base.Load(br);
|
||||
Width = br.ReadDouble();
|
||||
Height = br.ReadDouble();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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(), 0);
|
||||
Cv2.BitwiseNot(context.ActiveImage.ImageData, res);
|
||||
context.ActiveImage = new HawkeyeImage()
|
||||
{
|
||||
ImageData = res
|
||||
};
|
||||
|
||||
Status = $"Image inverted";
|
||||
Result = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user