Skip to content

Commit 4033deb

Browse files
committed
Add morphology operation
1 parent 978b4a9 commit 4033deb

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

core/src/main/java/edu/wpi/grip/core/operations/CVOperations.java

+37-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,28 @@ public class CVOperations {
309309
}
310310
)),
311311

312-
new OperationMetaData(CVOperation.defaults("CV rectangle",
312+
new OperationMetaData(CVOperation.defaults("CV morphologyEx",
313+
"Performs advanced morphological transformations."),
314+
templateFactory.create(
315+
SocketHints.Inputs.createMatSocketHint("src", false),
316+
SocketHints.Inputs.createMatSocketHint("kernel", true),
317+
SocketHints.createEnumSocketHint("op", CVMorphologyTypesEnum.MORPH_OPEN),
318+
new SocketHint.Builder<>(Point.class).identifier("anchor").initialValueSupplier(
319+
() -> new Point(-1, -1)).build(),
320+
SocketHints.Inputs.createNumberSpinnerSocketHint("iterations", 1),
321+
SocketHints.createEnumSocketHint("borderType", BorderTypesEnum.BORDER_CONSTANT),
322+
new SocketHint.Builder<>(Scalar.class).identifier("borderValue")
323+
.initialValueSupplier(opencv_imgproc::morphologyDefaultBorderValue).build(),
324+
SocketHints.Outputs.createMatSocketHint("dst"),
325+
(src, kernel, op, anchor, iterations, borderType, borderValue, dst) -> {
326+
opencv_imgproc.morphologyEx(src, dst, op.value, kernel, anchor,
327+
iterations.intValue(), borderType.value, borderValue);
328+
}
329+
)),
330+
331+
332+
333+
new OperationMetaData(CVOperation.defaults("CV rectangle",
313334
"Draw a rectangle (outline or filled) on an image."),
314335
templateFactory.create(
315336
SocketHints.Inputs.createMatSocketHint("src", false),
@@ -426,6 +447,21 @@ public enum CVBorderTypesEnum {
426447
}
427448
}
428449

450+
public enum CVMorphologyTypesEnum {
451+
MORPH_OPEN(2),
452+
MORPH_CLOSE(3),
453+
MORPH_GRADIENT(4),
454+
MORPH_TOPHAT(5),
455+
MORPH_BLACKHAT(6),
456+
MORPH_HITMISS(7);
457+
458+
public final int value;
459+
460+
CVMorphologyTypesEnum(int value) {
461+
this.value = value;
462+
}
463+
}
464+
429465

430466
/**
431467
* All of the operations that this list supplies.

0 commit comments

Comments
 (0)