Fix the slider init.

git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4134 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/971CV/src/org/frc971/Recognizer2013.java b/971CV/src/org/frc971/Recognizer2013.java
index d2de431..0caf1f1 100644
--- a/971CV/src/org/frc971/Recognizer2013.java
+++ b/971CV/src/org/frc971/Recognizer2013.java
@@ -27,10 +27,6 @@
     // --- Constants that need to be tuned.

     static final double kRoughlyHorizontalSlope = Math.tan(Math.toRadians(30));

     static final double kRoughlyVerticalSlope = Math.tan(Math.toRadians(90 - 30));

-    private int min1Hue;

-    private int max1Hue;

-    private int min1Sat;

-    private int min1Val;

     static final int kHoleClosingIterations = 2;

     static final double kPolygonPercentFit = 12;

 

@@ -52,6 +48,8 @@
     private static final WPIColor candidateColor = WPIColor.BLUE;

     private static final WPIColor targetColor = new WPIColor(255, 0, 0);

 

+    private int min1Hue, max1Hue, min1Sat, min1Val;

+

     // Show intermediate images for parameter tuning.

     private final DebugCanvas thresholdedCanvas = new DebugCanvas("thresholded");

     private final DebugCanvas morphedCanvas = new DebugCanvas("morphed");

@@ -89,9 +87,9 @@
     @Override

     public int getHueMax() { return max1Hue - 1; }

     @Override

-    public int getSatMin() { return min1Sat - 1; }

+    public int getSatMin() { return min1Sat + 1; }

     @Override

-    public int getValMin() { return min1Val - 1; }

+    public int getValMin() { return min1Val + 1; }

 

     @Override

     public void showIntermediateStages(boolean enable) {

@@ -136,7 +134,6 @@
 

         // NOTE: Since red is at the end of the cyclic color space, you can OR

         // a threshold and an inverted threshold to match red pixels.

-        // TODO(jerry): Use tunable constants instead of literals.

         opencv_imgproc.cvThreshold(hue, bin, min1Hue, 255, opencv_imgproc.CV_THRESH_BINARY);

         opencv_imgproc.cvThreshold(hue, hue, max1Hue, 255, opencv_imgproc.CV_THRESH_BINARY_INV);

         opencv_imgproc.cvThreshold(sat, sat, min1Sat, 255, opencv_imgproc.CV_THRESH_BINARY);

@@ -157,11 +154,6 @@
         morphedCanvas.showImage(bin);

 

         // Find contours.

-        //

-        // TODO(jerry): Request contours as a two-level hierarchy (blobs and

-        // holes)? The targets have known sizes and their holes have known,

-        // smaller sizes. This matters for distance measurement. OTOH it's moot

-        // if/when we use the vertical stripes for distance measurement.

         WPIBinaryImage binWpi = DaisyExtensions.makeWPIBinaryImage(bin);

         WPIContour[] contours = daisyExtensions.findConvexContours(binWpi);

 

diff --git a/971CV/src/org/frc971/VisionTuner.java b/971CV/src/org/frc971/VisionTuner.java
index c231743..0a1e1e9 100644
--- a/971CV/src/org/frc971/VisionTuner.java
+++ b/971CV/src/org/frc971/VisionTuner.java
@@ -72,9 +72,9 @@
             public void stateChanged(ChangeEvent e) {

                 System.out.println("New HSV range ["

                         + hueMinSlider.getValue() + " .. "

-                        + hueMaxSlider.getValue() + "], ["

-                        + satMinSlider.getValue() + " .. 255], ["

-                        + valMinSlider.getValue() + " .. 255]");

+                        + hueMaxSlider.getValue() + "] "

+                        + satMinSlider.getValue() + "+ "

+                        + valMinSlider.getValue() + "+");

                 recognizer.setHSVRange(

                         hueMinSlider.getValue(), hueMaxSlider.getValue(),

                         satMinSlider.getValue(),

@@ -83,26 +83,32 @@
             }

         };

 

-        hueMinSlider.setValue(recognizer.getHueMin());

         hueMinSlider.setToolTipText("minimum HSV hue");

         hueMinSlider.setMaximum(255);

+        hueMinSlider.setValue(recognizer.getHueMin());

         panel.add(hueMinSlider);

 

-        hueMaxSlider.setValue(recognizer.getHueMax());

         hueMaxSlider.setToolTipText("maximum HSV hue");

         hueMaxSlider.setMaximum(255);

+        hueMaxSlider.setValue(recognizer.getHueMax());

         panel.add(hueMaxSlider);

 

-        satMinSlider.setValue(recognizer.getSatMin());

         satMinSlider.setToolTipText("minimum HSV color saturation");

         satMinSlider.setMaximum(255);

+        satMinSlider.setValue(recognizer.getSatMin());

         panel.add(satMinSlider);

 

-        valMinSlider.setValue(recognizer.getValMin());

         valMinSlider.setToolTipText("minimum HSV brightness value");

         valMinSlider.setMaximum(255);

+        valMinSlider.setValue(recognizer.getValMin());

         panel.add(valMinSlider);

 

+        System.out.println("Initial HSV range ["

+                + hueMinSlider.getValue() + " .. "

+                + hueMaxSlider.getValue() + "] "

+                + satMinSlider.getValue() + "+ "

+                + valMinSlider.getValue() + "+");

+

         hueMinSlider.addChangeListener(sliderListener);

         hueMaxSlider.addChangeListener(sliderListener);

         satMinSlider.addChangeListener(sliderListener);