Skip to content

Commit 85455d0

Browse files
committed
Merge branch 'master' into spinner-bug
2 parents c7273b2 + 2d7b748 commit 85455d0

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

core/src/main/java/edu/wpi/grip/core/operations/composite/HSLThresholdOperation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* An {@link edu.wpi.grip.core.Operation} that converts a color image into a binary image based on the HSL threshold ranges
2121
*/
2222
public class HSLThresholdOperation extends ThresholdOperation {
23-
private static final Logger logger = Logger.getLogger(HSLThresholdOperation.class.getName());
23+
private static final Logger logger = Logger.getLogger(HSLThresholdOperation.class.getName());
2424
private final SocketHint<Mat> inputHint = SocketHints.Inputs.createMatSocketHint("Input", false);
2525
private final SocketHint<List> hueHint = SocketHints.Inputs.createNumberListRangeSocketHint("Hue", 0.0, 180.0);
2626
private final SocketHint<List> saturationHint = SocketHints.Inputs.createNumberListRangeSocketHint("Saturation", 0.0, 255.0);
@@ -64,6 +64,10 @@ public void perform(InputSocket<?>[] inputs, OutputSocket<?>[] outputs, Optional
6464
final List<Number> channel2 = ((InputSocket<List<Number>>) inputs[2]).getValue().get();
6565
final List<Number> channel3 = ((InputSocket<List<Number>>) inputs[3]).getValue().get();
6666

67+
if (input.channels() != 3) {
68+
throw new IllegalArgumentException("HSL Threshold needs a 3-channel input");
69+
}
70+
6771
final OutputSocket<Mat> outputSocket = (OutputSocket<Mat>) outputs[0];
6872
final Mat output = outputSocket.getValue().get();
6973

core/src/main/java/edu/wpi/grip/core/operations/composite/HSVThresholdOperation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
public class HSVThresholdOperation extends ThresholdOperation {
2424

25-
private static final Logger logger = Logger.getLogger(HSVThresholdOperation.class.getName());
25+
private static final Logger logger = Logger.getLogger(HSVThresholdOperation.class.getName());
2626
private final SocketHint<Mat> inputHint = SocketHints.Inputs.createMatSocketHint("Input", false);
2727
private final SocketHint<List> hueHint = SocketHints.Inputs.createNumberListRangeSocketHint("Hue", 0.0, 180.0);
2828
private final SocketHint<List> saturationHint = SocketHints.Inputs.createNumberListRangeSocketHint("Saturation", 0.0, 255.0);
@@ -67,6 +67,10 @@ public void perform(InputSocket<?>[] inputs, OutputSocket<?>[] outputs, Optional
6767
final List<Number> channel2 = ((InputSocket<List<Number>>) inputs[2]).getValue().get();
6868
final List<Number> channel3 = ((InputSocket<List<Number>>) inputs[3]).getValue().get();
6969

70+
if (input.channels() != 3) {
71+
throw new IllegalArgumentException("HSV Threshold needs a 3-channel input");
72+
}
73+
7074
final OutputSocket<Mat> outputSocket = (OutputSocket<Mat>) outputs[0];
7175
final Mat output = outputSocket.getValue().get();
7276

core/src/main/java/edu/wpi/grip/core/operations/composite/RGBThresholdOperation.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
public class RGBThresholdOperation extends ThresholdOperation {
1717

18-
private static final Logger logger = Logger.getLogger(RGBThresholdOperation.class.getName());
18+
private static final Logger logger = Logger.getLogger(RGBThresholdOperation.class.getName());
1919
private final SocketHint<Mat> inputHint = SocketHints.Inputs.createMatSocketHint("Input", false);
2020
private final SocketHint<List> redHint = SocketHints.Inputs.createNumberListRangeSocketHint("Red", 0.0, 255.0);
2121
private final SocketHint<List> greenHint = SocketHints.Inputs.createNumberListRangeSocketHint("Green", 0.0, 255.0);
@@ -65,6 +65,10 @@ public void perform(InputSocket<?>[] inputs, OutputSocket<?>[] outputs, Optional
6565
final List<Number> channel2 = ((InputSocket<List<Number>>) inputs[2]).getValue().get();
6666
final List<Number> channel3 = ((InputSocket<List<Number>>) inputs[3]).getValue().get();
6767

68+
if (input.channels() != 3) {
69+
throw new IllegalArgumentException("RGB Threshold needs a 3-channel input");
70+
}
71+
6872
final OutputSocket<Mat> outputSocket = (OutputSocket<Mat>) outputs[0];
6973
final Mat output = outputSocket.getValue().get();
7074

0 commit comments

Comments
 (0)