@@ -33,6 +33,10 @@ public class FindBlobsOperation implements Operation {
33
33
.createNumberSpinnerSocketHint ("Min Area" , 1 );
34
34
private final SocketHint <List <Number >> circularityHint = SocketHints .Inputs
35
35
.createNumberListRangeSocketHint ("Circularity" , 0.0 , 1.0 );
36
+ private final SocketHint <List <Number >> convexityHint = SocketHints .Inputs
37
+ .createNumberListRangeSocketHint ("Convexity" , 0.0 , 1.0 );
38
+ private final SocketHint <List <Number >> inertiaRatioHint = SocketHints .Inputs
39
+ .createNumberListRangeSocketHint ("Inertia Ratio" , 0.0 , 1.0 );
36
40
private final SocketHint <Boolean > colorHint = SocketHints
37
41
.createBooleanSocketHint ("Dark Blobs" , false );
38
42
@@ -44,6 +48,8 @@ public class FindBlobsOperation implements Operation {
44
48
private final InputSocket <Mat > inputSocket ;
45
49
private final InputSocket <Number > minAreaSocket ;
46
50
private final InputSocket <List <Number >> circularitySocket ;
51
+ private final InputSocket <List <Number >> convexitySocket ;
52
+ private final InputSocket <List <Number >> inertiaRatioSocket ;
47
53
private final InputSocket <Boolean > colorSocket ;
48
54
49
55
private final OutputSocket <BlobsReport > outputSocket ;
@@ -55,6 +61,8 @@ public FindBlobsOperation(InputSocket.Factory inputSocketFactory, OutputSocket.F
55
61
this .inputSocket = inputSocketFactory .create (inputHint );
56
62
this .minAreaSocket = inputSocketFactory .create (minAreaHint );
57
63
this .circularitySocket = inputSocketFactory .create (circularityHint );
64
+ this .convexitySocket = inputSocketFactory .create (convexityHint );
65
+ this .inertiaRatioSocket = inputSocketFactory .create (inertiaRatioHint );
58
66
this .colorSocket = inputSocketFactory .create (colorHint );
59
67
60
68
this .outputSocket = outputSocketFactory .create (blobsHint );
@@ -66,6 +74,8 @@ public List<InputSocket> getInputSockets() {
66
74
inputSocket ,
67
75
minAreaSocket ,
68
76
circularitySocket ,
77
+ convexitySocket ,
78
+ inertiaRatioSocket ,
69
79
colorSocket
70
80
);
71
81
}
@@ -83,6 +93,8 @@ public void perform() {
83
93
final Mat input = inputSocket .getValue ().get ();
84
94
final Number minArea = minAreaSocket .getValue ().get ();
85
95
final List <Number > circularity = circularitySocket .getValue ().get ();
96
+ final List <Number > convexity = convexitySocket .getValue ().get ();
97
+ final List <Number > inertiaRatio = inertiaRatioSocket .getValue ().get ();
86
98
final Boolean darkBlobs = colorSocket .getValue ().get ();
87
99
88
100
@@ -97,7 +109,15 @@ public void perform() {
97
109
98
110
.filterByCircularity (true )
99
111
.minCircularity (circularity .get (0 ).floatValue ())
100
- .maxCircularity (circularity .get (1 ).floatValue ()));
112
+ .maxCircularity (circularity .get (1 ).floatValue ())
113
+
114
+ .filterByConvexity (true )
115
+ .minConvexity (convexity .get (0 ).floatValue ())
116
+ .maxConvexity (convexity .get (1 ).floatValue ())
117
+
118
+ .filterByInertia (true )
119
+ .minInertiaRatio (inertiaRatio .get (0 ).floatValue ())
120
+ .maxInertiaRatio (inertiaRatio .get (1 ).floatValue ()));
101
121
102
122
// Detect the blobs and store them in the output BlobsReport
103
123
final KeyPointVector keyPointVector = new KeyPointVector ();
0 commit comments