@@ -34,6 +34,10 @@ public class FindBlobsOperation implements Operation {
3434 .createNumberSpinnerSocketHint ("Min Area" , 1 );
3535 private final SocketHint <List <Number >> circularityHint = SocketHints .Inputs
3636 .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 );
3741 private final SocketHint <Boolean > colorHint = SocketHints
3842 .createBooleanSocketHint ("Dark Blobs" , false );
3943
@@ -45,6 +49,8 @@ public class FindBlobsOperation implements Operation {
4549 private final InputSocket <MatWrapper > inputSocket ;
4650 private final InputSocket <Number > minAreaSocket ;
4751 private final InputSocket <List <Number >> circularitySocket ;
52+ private final InputSocket <List <Number >> convexitySocket ;
53+ private final InputSocket <List <Number >> inertiaRatioSocket ;
4854 private final InputSocket <Boolean > colorSocket ;
4955
5056 private final OutputSocket <BlobsReport > outputSocket ;
@@ -56,6 +62,8 @@ public FindBlobsOperation(InputSocket.Factory inputSocketFactory, OutputSocket.F
5662 this .inputSocket = inputSocketFactory .create (inputHint );
5763 this .minAreaSocket = inputSocketFactory .create (minAreaHint );
5864 this .circularitySocket = inputSocketFactory .create (circularityHint );
65+ this .convexitySocket = inputSocketFactory .create (convexityHint );
66+ this .inertiaRatioSocket = inputSocketFactory .create (inertiaRatioHint );
5967 this .colorSocket = inputSocketFactory .create (colorHint );
6068
6169 this .outputSocket = outputSocketFactory .create (blobsHint );
@@ -67,6 +75,8 @@ public List<InputSocket> getInputSockets() {
6775 inputSocket ,
6876 minAreaSocket ,
6977 circularitySocket ,
78+ convexitySocket ,
79+ inertiaRatioSocket ,
7080 colorSocket
7181 );
7282 }
@@ -84,6 +94,8 @@ public void perform() {
8494 final Mat input = inputSocket .getValue ().get ().getCpu ();
8595 final Number minArea = minAreaSocket .getValue ().get ();
8696 final List <Number > circularity = circularitySocket .getValue ().get ();
97+ final List <Number > convexity = convexitySocket .getValue ().get ();
98+ final List <Number > inertiaRatio = inertiaRatioSocket .getValue ().get ();
8799 final Boolean darkBlobs = colorSocket .getValue ().get ();
88100
89101
@@ -98,7 +110,15 @@ public void perform() {
98110
99111 .filterByCircularity (true )
100112 .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 ()));
102122
103123 // Detect the blobs and store them in the output BlobsReport
104124 final KeyPointVector keyPointVector = new KeyPointVector ();
0 commit comments