A skeletal machine vision program.
Tap the left and right arrow keys to step through the test images.

git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4115 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/971CV/.classpath b/971CV/.classpath
new file mode 100644
index 0000000..01eafa6
--- /dev/null
+++ b/971CV/.classpath
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<classpath>

+	<classpathentry kind="src" path="src"/>

+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

+	<classpathentry kind="lib" path="C:/WindRiver/WPILib/desktop-lib/networktables-desktop.jar" sourcepath="C:/WindRiver/WPILib/desktop-lib/networktables-desktop.src.zip">

+		<attributes>

+			<attribute name="javadoc_location" value="jar:file:/C:/WindRiver/WPILib/desktop-lib/networktables-desktop.javadoc.zip!/"/>

+		</attributes>

+	</classpathentry>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/SmartDashboard.jar" sourcepath="C:/sourcecontrolled/FIRSTforge/SmartDashboard/trunk/smartdashboard/src"/>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/extensions/WPICameraExtension.jar" sourcepath="C:/sourcecontrolled/FIRSTforge/SmartDashboard/trunk/extensions"/>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/extensions/lib/javacpp.jar"/>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/extensions/lib/javacv.jar">

+		<attributes>

+			<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:/Program Files/WPIJavaCV/OpenCV_2.2.0/bin"/>

+		</attributes>

+	</classpathentry>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/extensions/lib/javacv-windows-x86.jar">

+		<attributes>

+			<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="C:/Program Files/WPIJavaCV/JavaCV_2.2.0/javacv-bin"/>

+		</attributes>

+	</classpathentry>

+	<classpathentry kind="lib" path="C:/Program Files/SmartDashboard/extensions/lib/WPIJavaCV.jar"/>

+	<classpathentry kind="output" path="bin"/>

+</classpath>

diff --git a/971CV/.project b/971CV/.project
new file mode 100644
index 0000000..2c09e79
--- /dev/null
+++ b/971CV/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>971CV</name>

+	<comment></comment>

+	<projects>

+	</projects>

+	<buildSpec>

+		<buildCommand>

+			<name>org.eclipse.jdt.core.javabuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+	</natures>

+</projectDescription>

diff --git a/971CV/2012-test-images/image-01.jpg b/971CV/2012-test-images/image-01.jpg
new file mode 100644
index 0000000..3816924
--- /dev/null
+++ b/971CV/2012-test-images/image-01.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-02.jpg b/971CV/2012-test-images/image-02.jpg
new file mode 100644
index 0000000..818ebf1
--- /dev/null
+++ b/971CV/2012-test-images/image-02.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-03.jpg b/971CV/2012-test-images/image-03.jpg
new file mode 100644
index 0000000..382212a
--- /dev/null
+++ b/971CV/2012-test-images/image-03.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-04.jpg b/971CV/2012-test-images/image-04.jpg
new file mode 100644
index 0000000..408fb7a
--- /dev/null
+++ b/971CV/2012-test-images/image-04.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-05.jpg b/971CV/2012-test-images/image-05.jpg
new file mode 100644
index 0000000..ab21d5e
--- /dev/null
+++ b/971CV/2012-test-images/image-05.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-06.jpg b/971CV/2012-test-images/image-06.jpg
new file mode 100644
index 0000000..9e963da
--- /dev/null
+++ b/971CV/2012-test-images/image-06.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-07.jpg b/971CV/2012-test-images/image-07.jpg
new file mode 100644
index 0000000..e00b774
--- /dev/null
+++ b/971CV/2012-test-images/image-07.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-08.jpg b/971CV/2012-test-images/image-08.jpg
new file mode 100644
index 0000000..147498f
--- /dev/null
+++ b/971CV/2012-test-images/image-08.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-09.jpg b/971CV/2012-test-images/image-09.jpg
new file mode 100644
index 0000000..ad8dcbd
--- /dev/null
+++ b/971CV/2012-test-images/image-09.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-10.jpg b/971CV/2012-test-images/image-10.jpg
new file mode 100644
index 0000000..34465bf
--- /dev/null
+++ b/971CV/2012-test-images/image-10.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-11.jpg b/971CV/2012-test-images/image-11.jpg
new file mode 100644
index 0000000..03522e7
--- /dev/null
+++ b/971CV/2012-test-images/image-11.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-12.jpg b/971CV/2012-test-images/image-12.jpg
new file mode 100644
index 0000000..b0317f2
--- /dev/null
+++ b/971CV/2012-test-images/image-12.jpg
Binary files differ
diff --git a/971CV/2012-test-images/image-13.jpg b/971CV/2012-test-images/image-13.jpg
new file mode 100644
index 0000000..c329779
--- /dev/null
+++ b/971CV/2012-test-images/image-13.jpg
Binary files differ
diff --git a/971CV/2013-test-images/45in_DoubleGreen.jpg b/971CV/2013-test-images/45in_DoubleGreen.jpg
new file mode 100644
index 0000000..84aacdf
--- /dev/null
+++ b/971CV/2013-test-images/45in_DoubleGreen.jpg
Binary files differ
diff --git a/971CV/2013-test-images/57inLargeTarget_DoubleGreenBK.jpg b/971CV/2013-test-images/57inLargeTarget_DoubleGreenBK.jpg
new file mode 100644
index 0000000..63448a7
--- /dev/null
+++ b/971CV/2013-test-images/57inLargeTarget_DoubleGreenBK.jpg
Binary files differ
diff --git a/971CV/2013-test-images/FullField_DoubleGreenBK3.jpg b/971CV/2013-test-images/FullField_DoubleGreenBK3.jpg
new file mode 100644
index 0000000..d9fd691
--- /dev/null
+++ b/971CV/2013-test-images/FullField_DoubleGreenBK3.jpg
Binary files differ
diff --git a/971CV/2013-test-images/FullField_SmallGreen.jpg b/971CV/2013-test-images/FullField_SmallGreen.jpg
new file mode 100644
index 0000000..a77646e
--- /dev/null
+++ b/971CV/2013-test-images/FullField_SmallGreen.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_DoubleGreenBK2.jpg b/971CV/2013-test-images/HybridLine_DoubleGreenBK2.jpg
new file mode 100644
index 0000000..a444bb8
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_DoubleGreenBK2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_DoubleGreenBK3.jpg b/971CV/2013-test-images/HybridLine_DoubleGreenBK3.jpg
new file mode 100644
index 0000000..8961b13
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_DoubleGreenBK3.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_DoubleGreenBK4.jpg b/971CV/2013-test-images/HybridLine_DoubleGreenBK4.jpg
new file mode 100644
index 0000000..356e44a
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_DoubleGreenBK4.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_SmallGreen2.jpg b/971CV/2013-test-images/HybridLine_SmallGreen2.jpg
new file mode 100644
index 0000000..08ccd6c
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_SmallGreen2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_SmallGreen3.jpg b/971CV/2013-test-images/HybridLine_SmallGreen3.jpg
new file mode 100644
index 0000000..e85630c
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_SmallGreen3.jpg
Binary files differ
diff --git a/971CV/2013-test-images/HybridLine_SmallGreen4.jpg b/971CV/2013-test-images/HybridLine_SmallGreen4.jpg
new file mode 100644
index 0000000..9274028
--- /dev/null
+++ b/971CV/2013-test-images/HybridLine_SmallGreen4.jpg
Binary files differ
diff --git a/971CV/2013-test-images/Midfield_DoubleGreenBK2.jpg b/971CV/2013-test-images/Midfield_DoubleGreenBK2.jpg
new file mode 100644
index 0000000..1703d2e
--- /dev/null
+++ b/971CV/2013-test-images/Midfield_DoubleGreenBK2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/Midfield_SmallGreen2.jpg b/971CV/2013-test-images/Midfield_SmallGreen2.jpg
new file mode 100644
index 0000000..49b69a0
--- /dev/null
+++ b/971CV/2013-test-images/Midfield_SmallGreen2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/Midfield_SmallGreen3.jpg b/971CV/2013-test-images/Midfield_SmallGreen3.jpg
new file mode 100644
index 0000000..c79dcf4
--- /dev/null
+++ b/971CV/2013-test-images/Midfield_SmallGreen3.jpg
Binary files differ
diff --git a/971CV/2013-test-images/Midfield_SmallGreen4.jpg b/971CV/2013-test-images/Midfield_SmallGreen4.jpg
new file mode 100644
index 0000000..7beb4f7
--- /dev/null
+++ b/971CV/2013-test-images/Midfield_SmallGreen4.jpg
Binary files differ
diff --git a/971CV/2013-test-images/OppLine_DoubleGreenBK2.jpg b/971CV/2013-test-images/OppLine_DoubleGreenBK2.jpg
new file mode 100644
index 0000000..627c184
--- /dev/null
+++ b/971CV/2013-test-images/OppLine_DoubleGreenBK2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/OppLine_SmallGreen2.jpg b/971CV/2013-test-images/OppLine_SmallGreen2.jpg
new file mode 100644
index 0000000..749c29d
--- /dev/null
+++ b/971CV/2013-test-images/OppLine_SmallGreen2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/PyramidRight_DoubleGreenBK2.jpg b/971CV/2013-test-images/PyramidRight_DoubleGreenBK2.jpg
new file mode 100644
index 0000000..853ed99
--- /dev/null
+++ b/971CV/2013-test-images/PyramidRight_DoubleGreenBK2.jpg
Binary files differ
diff --git a/971CV/2013-test-images/PyramidRight_SmallGreen2.jpg b/971CV/2013-test-images/PyramidRight_SmallGreen2.jpg
new file mode 100644
index 0000000..c1b1b6a
--- /dev/null
+++ b/971CV/2013-test-images/PyramidRight_SmallGreen2.jpg
Binary files differ
diff --git a/971CV/src/org/frc971/VisionTuner.java b/971CV/src/org/frc971/VisionTuner.java
new file mode 100644
index 0000000..7ecd98a
--- /dev/null
+++ b/971CV/src/org/frc971/VisionTuner.java
@@ -0,0 +1,120 @@
+package org.frc971;

+

+import java.awt.event.KeyEvent;

+import java.io.File;

+import java.io.IOException;

+

+import javax.imageio.ImageIO;

+import javax.swing.WindowConstants;

+

+import com.googlecode.javacv.CanvasFrame;

+

+import edu.wpi.first.wpijavacv.WPIColorImage;

+

+/* REQUIRED JAVA LIBRARIES:

+ *   Program Files/SmartDashboard/

+ *     extensions/lib/javacpp.jar

+ *     extensions/lib/javacv-YOUR_OS.jar

+ *     extensions/lib/javacv.jar

+ *     extensions/lib/WPIJavaCV.jar

+ *     SmartDashboard.jar                 -- maybe in the future

+ *     extensions/WPICameraExtension.jar  -- maybe in the future

+ *

+ * REQUIRED NATIVE CODE LIBRARIES:

+ *   Program Files/WPIJavaCV/

+ *     JavaCV_2.2.0/javacv-bin/javacv-YOUR_OS.jar

+ *     OpenCV_2.2.0/bin/*

+ */

+/**

+ * FRC 2013 vision-target recognizer tuner app.

+ *

+ * @author jerry

+ */

+public class VisionTuner {

+    private String[] testImageFilenames;

+    private WPIColorImage[] testImages;

+    private final CanvasFrame cameraFrame = new CanvasFrame("Camera");

+    private int currentIndex = 0;

+

+    public VisionTuner(String[] imageFilenames) {

+        cameraFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

+        cameraFrame.setFocusable(true);

+        cameraFrame.requestFocus();

+

+        loadTestImages(imageFilenames);

+    }

+

+

+    /**

+     * Loads the named test image files.

+     * Sets testImageFilenames and testImages.

+     */

+    private void loadTestImages(String[] imageFilenames) {

+	testImageFilenames = imageFilenames;

+	testImages = new WPIColorImage[testImageFilenames.length];

+

+	for (int i = 0; i < testImageFilenames.length; i++) {

+            String imageFilename = testImageFilenames[i];

+

+            System.out.println("Loading image file: " + imageFilename);

+            WPIColorImage rawImage = null;

+            try {

+                rawImage = new WPIColorImage(ImageIO.read(new File(imageFilename)));

+            } catch (IOException e) {

+                System.err.println("Couldn't load image file: " + imageFilename + ": " + e.getMessage());

+                System.exit(1);

+                return;

+            }

+            testImages[i] = rawImage;

+	}

+    }

+

+    private void processCurrentImage() {

+        WPIColorImage rawImage = testImages[currentIndex];

+        cameraFrame.showImage(rawImage.getBufferedImage());

+        cameraFrame.setTitle(testImageFilenames[currentIndex]);

+    }

+

+    private void previousImage() {

+	if (currentIndex > 0) {

+	    --currentIndex;

+	}

+	processCurrentImage();

+    }

+

+    private void nextImage() {

+	if (currentIndex + 1 < testImages.length) {

+	    ++currentIndex;

+	}

+	processCurrentImage();

+    }

+

+    private void processEvents() {

+	KeyEvent e = cameraFrame.waitKey();

+

+	switch (e.getKeyCode()) {

+	case KeyEvent.VK_LEFT:

+	    previousImage();

+	    break;

+	case KeyEvent.VK_RIGHT:

+	    nextImage();

+	    break;

+	}

+    }

+

+    public static void main(final String[] args) {

+        if (args.length == 0) {

+            System.err.println("Usage: " + VisionTuner.class.getName()

+        	    + " test image filenames...");

+            System.exit(1);

+        }

+

+        VisionTuner tuner = new VisionTuner(args);

+        tuner.processCurrentImage();

+

+        for (;;) {

+            tuner.processEvents();

+        }

+    }

+

+}