From 1bfed730dbfe43c84081f42d6f9d986ab6fce1e4 Mon Sep 17 00:00:00 2001 From: Tim Winters Date: Wed, 27 Dec 2017 19:22:33 -0500 Subject: [PATCH] Add morphology operation --- .../grip/core/operations/CVOperations.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java b/core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java index af12ad0da7..7d138f59a5 100644 --- a/core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java +++ b/core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java @@ -309,7 +309,28 @@ public class CVOperations { } )), - new OperationMetaData(CVOperation.defaults("CV rectangle", + new OperationMetaData(CVOperation.defaults("CV morphologyEx", + "Performs advanced morphological transformations."), + templateFactory.create( + SocketHints.Inputs.createMatSocketHint("src", false), + SocketHints.Inputs.createMatSocketHint("kernel", true), + SocketHints.createEnumSocketHint("op", CVMorphologyTypesEnum.MORPH_OPEN), + new SocketHint.Builder<>(Point.class).identifier("anchor").initialValueSupplier( + () -> new Point(-1, -1)).build(), + SocketHints.Inputs.createNumberSpinnerSocketHint("iterations", 1), + SocketHints.createEnumSocketHint("borderType", BorderTypesEnum.BORDER_CONSTANT), + new SocketHint.Builder<>(Scalar.class).identifier("borderValue") + .initialValueSupplier(opencv_imgproc::morphologyDefaultBorderValue).build(), + SocketHints.Outputs.createMatSocketHint("dst"), + (src, kernel, op, anchor, iterations, borderType, borderValue, dst) -> { + opencv_imgproc.morphologyEx(src, dst, op.value, kernel, anchor, iterations.intValue(), + borderType.value, borderValue); + } + )), + + + + new OperationMetaData(CVOperation.defaults("CV rectangle", "Draw a rectangle (outline or filled) on an image."), templateFactory.create( SocketHints.Inputs.createMatSocketHint("src", false), @@ -426,6 +447,20 @@ public enum CVBorderTypesEnum { } } + public enum CVMorphologyTypesEnum{ + MORPH_OPEN(2), + MORPH_CLOSE(3), + MORPH_GRADIENT(4), + MORPH_TOPHAT(5), + MORPH_BLACKHAT(6), + MORPH_HITMISS(7); + + public final int value; + + CVMorphologyTypesEnum(int value) { this.value = value;} + + } + /** * All of the operations that this list supplies.