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