@@ -33,6 +33,10 @@ public class FindBlobsOperation implements Operation {
3333 .createNumberSpinnerSocketHint ("Min Area" , 1 );
3434 private final SocketHint <List <Number >> circularityHint = SocketHints .Inputs
3535 .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 );
3640 private final SocketHint <Boolean > colorHint = SocketHints
3741 .createBooleanSocketHint ("Dark Blobs" , false );
3842
@@ -44,6 +48,8 @@ public class FindBlobsOperation implements Operation {
4448 private final InputSocket <Mat > inputSocket ;
4549 private final InputSocket <Number > minAreaSocket ;
4650 private final InputSocket <List <Number >> circularitySocket ;
51+ private final InputSocket <List <Number >> convexitySocket ;
52+ private final InputSocket <List <Number >> inertiaRatioSocket ;
4753 private final InputSocket <Boolean > colorSocket ;
4854
4955 private final OutputSocket <BlobsReport > outputSocket ;
@@ -55,6 +61,8 @@ public FindBlobsOperation(InputSocket.Factory inputSocketFactory, OutputSocket.F
5561 this .inputSocket = inputSocketFactory .create (inputHint );
5662 this .minAreaSocket = inputSocketFactory .create (minAreaHint );
5763 this .circularitySocket = inputSocketFactory .create (circularityHint );
64+ this .convexitySocket = inputSocketFactory .create (convexityHint );
65+ this .inertiaRatioSocket = inputSocketFactory .create (inertiaRatioHint );
5866 this .colorSocket = inputSocketFactory .create (colorHint );
5967
6068 this .outputSocket = outputSocketFactory .create (blobsHint );
@@ -66,6 +74,8 @@ public List<InputSocket> getInputSockets() {
6674 inputSocket ,
6775 minAreaSocket ,
6876 circularitySocket ,
77+ convexitySocket ,
78+ inertiaRatioSocket ,
6979 colorSocket
7080 );
7181 }
@@ -83,6 +93,8 @@ public void perform() {
8393 final Mat input = inputSocket .getValue ().get ();
8494 final Number minArea = minAreaSocket .getValue ().get ();
8595 final List <Number > circularity = circularitySocket .getValue ().get ();
96+ final List <Number > convexity = convexitySocket .getValue ().get ();
97+ final List <Number > inertiaRatio = inertiaRatioSocket .getValue ().get ();
8698 final Boolean darkBlobs = colorSocket .getValue ().get ();
8799
88100
@@ -97,7 +109,15 @@ public void perform() {
97109
98110 .filterByCircularity (true )
99111 .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 ()));
101121
102122 // Detect the blobs and store them in the output BlobsReport
103123 final KeyPointVector keyPointVector = new KeyPointVector ();
0 commit comments