Skip to content

Commit 2da6dec

Browse files
committed
Add boulder detection.
1 parent 2811168 commit 2da6dec

File tree

1 file changed

+88
-45
lines changed

1 file changed

+88
-45
lines changed

src/main/java/org/usfirst/frc/team2084/smartdashboard/extensions/vision/VisionExtension.java

+88-45
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,39 @@ public abstract class VisionExtension extends UDPStreamViewerExtension {
4444
public static final Range COLOR_RANGE = new Range(0, 255);
4545

4646
// Various properties that appear in the properties editor of the extension.
47-
public final RangeProperty hThreshold = new RangeProperty(this, "H Threshold", COLOR_RANGE, DEFAULT_H_THRESHOLD);
48-
public final RangeProperty sThreshold = new RangeProperty(this, "S Threshold", COLOR_RANGE, DEFAULT_S_THRESHOLD);
49-
public final RangeProperty vThreshold = new RangeProperty(this, "V Threshold", COLOR_RANGE, DEFAULT_V_THRESHOLD);
50-
public final DoubleProperty minArea = new DoubleProperty(this, "Min Blob Area", DEFAULT_MIN_BLOB_SIZE);
51-
public final DoubleProperty minAspectRatioScore =
52-
new DoubleProperty(this, "Min Aspect Ratio Score", DEFAULT_MIN_ASPECT_RATIO_SCORE);
53-
public final DoubleProperty minRectangularityWidthScore =
54-
new DoubleProperty(this, "Min Rect Width Score", DEFAULT_MIN_RECTANGULARITY_WIDTH_SCORE);
55-
public final DoubleProperty minRectangularityHeightScore =
56-
new DoubleProperty(this, "Min Rect Height Score", DEFAULT_MIN_RECTANGULARITY_HEIGHT_SCORE);
57-
public final DoubleProperty approxPolyEpsilon =
58-
new DoubleProperty(this, "Approx Poly Epsilon", DEFAULT_APPROX_POLY_EPSILON);
59-
public final IntegerProperty blurSize = new IntegerProperty(this, "Blur Size", DEFAULT_BLUR_SIZE);
47+
public final RangeProperty goalHThreshold =
48+
new RangeProperty(this, "Goal H Threshold", COLOR_RANGE, DEFAULT_GOAL_H_THRESHOLD);
49+
public final RangeProperty goalSThreshold =
50+
new RangeProperty(this, "Goal S Threshold", COLOR_RANGE, DEFAULT_GOAL_S_THRESHOLD);
51+
public final RangeProperty goalVThreshold =
52+
new RangeProperty(this, "Goal V Threshold", COLOR_RANGE, DEFAULT_GOAL_V_THRESHOLD);
53+
public final DoubleProperty goalMinArea =
54+
new DoubleProperty(this, "Goal Min Blob Area", DEFAULT_GOAL_MIN_BLOB_AREA);
55+
public final DoubleProperty goalMinAspectRatioScore =
56+
new DoubleProperty(this, "Goal Min Aspect Ratio Score", DEFAULT_GOAL_MIN_ASPECT_RATIO_SCORE);
57+
public final DoubleProperty goalMinRectangularityWidthScore =
58+
new DoubleProperty(this, "Goal Min Rect Width Score", DEFAULT_GOAL_MIN_RECTANGULARITY_WIDTH_SCORE);
59+
public final DoubleProperty goalMinRectangularityHeightScore =
60+
new DoubleProperty(this, "Goal Min Rect Height Score", DEFAULT_GOAL_MIN_RECTANGULARITY_HEIGHT_SCORE);
61+
public final DoubleProperty goalMaxDistance =
62+
new DoubleProperty(this, "Goal Max Distance", DEFAULT_GOAL_MAX_DISTANCE);
63+
public final DoubleProperty goalMinDistance =
64+
new DoubleProperty(this, "Goal Min Distance", DEFAULT_GOAL_MIN_DISTANCE);
65+
public final DoubleProperty goalApproxPolyEpsilon =
66+
new DoubleProperty(this, "Goal Approx Poly Epsilon", DEFAULT_GOAL_APPROX_POLY_EPSILON);
67+
public final IntegerProperty goalBlurSize = new IntegerProperty(this, "Goal Blur Size", DEFAULT_GOAL_BLUR_SIZE);
68+
public final DoubleProperty aimingExposure = new DoubleProperty(this, "Aiming Exposure", DEFAULT_AIMING_EXPOSURE);
69+
70+
public final RangeProperty boulderHThreshold =
71+
new RangeProperty(this, "Boulder H Threshold", COLOR_RANGE, DEFAULT_GOAL_H_THRESHOLD);
72+
public final RangeProperty boulderSThreshold =
73+
new RangeProperty(this, "Boulder S Threshold", COLOR_RANGE, DEFAULT_GOAL_S_THRESHOLD);
74+
public final RangeProperty boulderVThreshold =
75+
new RangeProperty(this, "Boulder V Threshold", COLOR_RANGE, DEFAULT_GOAL_V_THRESHOLD);
76+
public final DoubleProperty boulderMinBlobArea =
77+
new DoubleProperty(this, "Boulder Min Blob Area", DEFAULT_GOAL_MIN_BLOB_AREA);
78+
6079
public final DoubleProperty fovAngle = new DoubleProperty(this, "FOV Angle", Math.toDegrees(DEFAULT_FOV_ANGLE));
61-
public final DoubleProperty exposure = new DoubleProperty(this, "Exposure", DEFAULT_EXPOSURE);
6280
public final IntegerProperty streamQuality = new IntegerProperty(this, "Stream Quality", DEFAULT_STREAM_QUALITY);
6381

6482
/**
@@ -69,17 +87,25 @@ public abstract class VisionExtension extends UDPStreamViewerExtension {
6987
public void init() {
7088
setPreferredSize(new Dimension(500, 500));
7189

72-
propertyChanged(hThreshold);
73-
propertyChanged(sThreshold);
74-
propertyChanged(vThreshold);
75-
propertyChanged(minArea);
76-
propertyChanged(minAspectRatioScore);
77-
propertyChanged(minRectangularityWidthScore);
78-
propertyChanged(minRectangularityHeightScore);
79-
propertyChanged(approxPolyEpsilon);
80-
propertyChanged(blurSize);
90+
propertyChanged(goalHThreshold);
91+
propertyChanged(goalSThreshold);
92+
propertyChanged(goalVThreshold);
93+
propertyChanged(goalMinArea);
94+
propertyChanged(goalMinAspectRatioScore);
95+
propertyChanged(goalMinRectangularityWidthScore);
96+
propertyChanged(goalMinRectangularityHeightScore);
97+
propertyChanged(goalMaxDistance);
98+
propertyChanged(goalMinDistance);
99+
propertyChanged(goalApproxPolyEpsilon);
100+
propertyChanged(goalBlurSize);
101+
propertyChanged(aimingExposure);
102+
103+
propertyChanged(boulderHThreshold);
104+
propertyChanged(boulderSThreshold);
105+
propertyChanged(boulderVThreshold);
106+
propertyChanged(boulderMinBlobArea);
107+
81108
propertyChanged(fovAngle);
82-
propertyChanged(exposure);
83109
propertyChanged(streamQuality);
84110

85111
super.init();
@@ -90,28 +116,45 @@ public void init() {
90116

91117
@Override
92118
public void propertyChanged(Property p) {
93-
if (p == hThreshold) {
94-
setHThreshold(hThreshold.getValue());
95-
} else if (p == sThreshold) {
96-
setSThreshold(sThreshold.getValue());
97-
} else if (p == vThreshold) {
98-
setVThreshold(vThreshold.getValue());
99-
} else if (p == minArea) {
100-
setMinBlobArea(minArea.getValue());
101-
} else if (p == minAspectRatioScore) {
102-
setMinAspectRatioScore(minAspectRatioScore.getValue());
103-
} else if (p == minRectangularityWidthScore) {
104-
setMinAspectRatioScore(minRectangularityWidthScore.getValue());
105-
} else if (p == minRectangularityHeightScore) {
106-
setMinAspectRatioScore(minRectangularityHeightScore.getValue());
107-
} else if (p == approxPolyEpsilon) {
108-
setApproxPolyEpsilon(approxPolyEpsilon.getValue());
109-
} else if (p == blurSize) {
110-
setBlurSize(blurSize.getValue());
111-
} else if (p == fovAngle) {
119+
////////////////////////////////////////// Goal parameters
120+
if (p == goalHThreshold) {
121+
setGoalHThreshold(goalHThreshold.getValue());
122+
} else if (p == goalSThreshold) {
123+
setGoalSThreshold(goalSThreshold.getValue());
124+
} else if (p == goalVThreshold) {
125+
setGoalVThreshold(goalVThreshold.getValue());
126+
} else if (p == goalMinArea) {
127+
setGoalMinBlobArea(goalMinArea.getValue());
128+
} else if (p == goalMinAspectRatioScore) {
129+
setGoalMinAspectRatioScore(goalMinAspectRatioScore.getValue());
130+
} else if (p == goalMinRectangularityWidthScore) {
131+
setGoalMinAspectRatioScore(goalMinRectangularityWidthScore.getValue());
132+
} else if (p == goalMinRectangularityHeightScore) {
133+
setGoalMinAspectRatioScore(goalMinRectangularityHeightScore.getValue());
134+
} else if (p == goalMaxDistance) {
135+
setGoalMaxDistance(goalMaxDistance.getValue());
136+
} else if (p == goalMinDistance) {
137+
setGoalMinDistance(goalMinDistance.getValue());
138+
} else if (p == goalApproxPolyEpsilon) {
139+
setApproxPolyEpsilon(goalApproxPolyEpsilon.getValue());
140+
} else if (p == goalBlurSize) {
141+
setGoalBlurSize(goalBlurSize.getValue());
142+
} else if (p == aimingExposure) {
143+
setAimingExposure(aimingExposure.getValue());
144+
}
145+
////////////////////////////////////////// Boulder parameters
146+
else if (p == boulderHThreshold) {
147+
setBoulderHThreshold(boulderHThreshold.getValue());
148+
} else if (p == boulderSThreshold) {
149+
setBoulderSThreshold(boulderSThreshold.getValue());
150+
} else if (p == boulderVThreshold) {
151+
setBoulderVThreshold(boulderVThreshold.getValue());
152+
} else if (p == boulderMinBlobArea) {
153+
setBoulderMinBlobArea(boulderMinBlobArea.getValue());
154+
}
155+
////////////////////////////////////////// General parameters
156+
else if (p == fovAngle) {
112157
setFOVAngleDegrees(fovAngle.getValue());
113-
} else if (p == exposure) {
114-
setExposure(exposure.getValue());
115158
} else if (p == streamQuality) {
116159
setStreamQuality(streamQuality.getValue());
117160
} else {

0 commit comments

Comments
 (0)