From 42ff123fea0f9fb8ed0c40ce2c3e21b64ff4bbf0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 9 Mar 2016 05:39:28 -0500 Subject: Clean up extensions. Renaming, code de-duplication --- .../ExampleSquareTrackerExtension/Square.pdf | Bin 0 -> 79845 bytes extensions/ExampleSquareTrackerExtension/build.xml | 74 ++ .../lib/SmartDashboard.jar | 1 + .../lib/WPIJavaCV.jar | 1 + .../lib/WPIJavaCVVideoExtension.jar | 1 + .../ExampleSquareTrackerExtension/lib/javacpp.jar | 1 + .../lib/javacv-windows-x86.jar | 1 + .../ExampleSquareTrackerExtension/lib/javacv.jar | 1 + .../ExampleSquareTrackerExtension/manifest.mf | 3 + .../nbproject/build-impl.xml | 1400 ++++++++++++++++++++ .../nbproject/genfiles.properties | 8 + .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 6 + .../nbproject/private/private.xml | 4 + .../nbproject/project.properties | 87 ++ .../nbproject/project.xml | 49 + .../extensions/squaretracker/Square.pdf | Bin 0 -> 79845 bytes .../squaretracker/SquareTrackerExtension.java | 119 ++ extensions/WPIJavaCVVideoExtension/build.xml | 74 ++ .../WPIJavaCVVideoExtension/lib/SmartDashboard.jar | 1 + .../WPIJavaCVVideoExtension/lib/WPIJavaCV.jar | 1 + extensions/WPIJavaCVVideoExtension/lib/javacpp.jar | 1 + .../lib/javacv-windows-x86.jar | 1 + extensions/WPIJavaCVVideoExtension/lib/javacv.jar | 1 + extensions/WPIJavaCVVideoExtension/manifest.mf | 3 + .../nbproject/build-impl.xml | 1400 ++++++++++++++++++++ .../nbproject/genfiles.properties | 8 + .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 6 + .../nbproject/private/private.xml | 4 + .../nbproject/project.properties | 96 ++ .../WPIJavaCVVideoExtension/nbproject/project.xml | 16 + .../wpijavacvvideo/AbstractVideoExtension.java | 166 +++ .../wpijavacvvideo/AxisCameraExtension.java | 51 + .../wpijavacvvideo/LaptopCameraExtension.java | 39 + .../extensions/wpijavacvvideo/Video.java | 13 + .../wpijavacvvideo/VideoURLExtension.java | 50 + extensions/camera/SquareTracker/Square.pdf | Bin 79845 -> 0 bytes extensions/camera/SquareTracker/build.xml | 74 -- extensions/camera/SquareTracker/manifest.mf | 3 - .../camera/SquareTracker/nbproject/build-impl.xml | 950 ------------- .../SquareTracker/nbproject/genfiles.properties | 8 - .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 6 - .../SquareTracker/nbproject/private/private.xml | 4 - .../SquareTracker/nbproject/project.properties | 91 -- .../camera/SquareTracker/nbproject/project.xml | 49 - .../wpilibj/examples/SquareTrackerExtension.java | 118 -- extensions/camera/WPICameraExtension/build.xml | 74 -- extensions/camera/WPICameraExtension/manifest.mf | 3 - .../WPICameraExtension/nbproject/build-impl.xml | 1400 -------------------- .../nbproject/genfiles.properties | 8 - .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 6 - .../nbproject/private/private.xml | 4 - .../nbproject/project.properties | 96 -- .../WPICameraExtension/nbproject/project.xml | 16 - .../camera/VideoStreamExtension.java | 166 --- .../camera/VideoStreamViewerExtension.java | 129 -- .../smartdashboard/camera/WPICameraExtension.java | 169 --- .../camera/WPIFFmpegVideoViewer.java | 133 -- .../camera/WPILaptopCameraExtension.java | 148 --- 62 files changed, 3687 insertions(+), 3655 deletions(-) create mode 100644 extensions/ExampleSquareTrackerExtension/Square.pdf create mode 100644 extensions/ExampleSquareTrackerExtension/build.xml create mode 120000 extensions/ExampleSquareTrackerExtension/lib/SmartDashboard.jar create mode 120000 extensions/ExampleSquareTrackerExtension/lib/WPIJavaCV.jar create mode 120000 extensions/ExampleSquareTrackerExtension/lib/WPIJavaCVVideoExtension.jar create mode 120000 extensions/ExampleSquareTrackerExtension/lib/javacpp.jar create mode 120000 extensions/ExampleSquareTrackerExtension/lib/javacv-windows-x86.jar create mode 120000 extensions/ExampleSquareTrackerExtension/lib/javacv.jar create mode 100644 extensions/ExampleSquareTrackerExtension/manifest.mf create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/build-impl.xml create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/genfiles.properties create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/private/config.properties create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/private/private.properties create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/private/private.xml create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/project.properties create mode 100644 extensions/ExampleSquareTrackerExtension/nbproject/project.xml create mode 100644 extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/Square.pdf create mode 100644 extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/SquareTrackerExtension.java create mode 100644 extensions/WPIJavaCVVideoExtension/build.xml create mode 120000 extensions/WPIJavaCVVideoExtension/lib/SmartDashboard.jar create mode 120000 extensions/WPIJavaCVVideoExtension/lib/WPIJavaCV.jar create mode 120000 extensions/WPIJavaCVVideoExtension/lib/javacpp.jar create mode 120000 extensions/WPIJavaCVVideoExtension/lib/javacv-windows-x86.jar create mode 120000 extensions/WPIJavaCVVideoExtension/lib/javacv.jar create mode 100644 extensions/WPIJavaCVVideoExtension/manifest.mf create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/build-impl.xml create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/genfiles.properties create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/private/config.properties create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/private/private.properties create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/private/private.xml create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/project.properties create mode 100644 extensions/WPIJavaCVVideoExtension/nbproject/project.xml create mode 100644 extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AbstractVideoExtension.java create mode 100644 extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AxisCameraExtension.java create mode 100644 extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/LaptopCameraExtension.java create mode 100644 extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/Video.java create mode 100644 extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/VideoURLExtension.java delete mode 100644 extensions/camera/SquareTracker/Square.pdf delete mode 100644 extensions/camera/SquareTracker/build.xml delete mode 100644 extensions/camera/SquareTracker/manifest.mf delete mode 100644 extensions/camera/SquareTracker/nbproject/build-impl.xml delete mode 100644 extensions/camera/SquareTracker/nbproject/genfiles.properties delete mode 100644 extensions/camera/SquareTracker/nbproject/private/config.properties delete mode 100644 extensions/camera/SquareTracker/nbproject/private/private.properties delete mode 100644 extensions/camera/SquareTracker/nbproject/private/private.xml delete mode 100644 extensions/camera/SquareTracker/nbproject/project.properties delete mode 100644 extensions/camera/SquareTracker/nbproject/project.xml delete mode 100644 extensions/camera/SquareTracker/src/edu/wpi/first/wpilibj/examples/SquareTrackerExtension.java delete mode 100644 extensions/camera/WPICameraExtension/build.xml delete mode 100644 extensions/camera/WPICameraExtension/manifest.mf delete mode 100644 extensions/camera/WPICameraExtension/nbproject/build-impl.xml delete mode 100644 extensions/camera/WPICameraExtension/nbproject/genfiles.properties delete mode 100644 extensions/camera/WPICameraExtension/nbproject/private/config.properties delete mode 100644 extensions/camera/WPICameraExtension/nbproject/private/private.properties delete mode 100644 extensions/camera/WPICameraExtension/nbproject/private/private.xml delete mode 100644 extensions/camera/WPICameraExtension/nbproject/project.properties delete mode 100644 extensions/camera/WPICameraExtension/nbproject/project.xml delete mode 100644 extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamExtension.java delete mode 100644 extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamViewerExtension.java delete mode 100644 extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPICameraExtension.java delete mode 100644 extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPIFFmpegVideoViewer.java delete mode 100644 extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPILaptopCameraExtension.java diff --git a/extensions/ExampleSquareTrackerExtension/Square.pdf b/extensions/ExampleSquareTrackerExtension/Square.pdf new file mode 100644 index 0000000..23cb55e Binary files /dev/null and b/extensions/ExampleSquareTrackerExtension/Square.pdf differ diff --git a/extensions/ExampleSquareTrackerExtension/build.xml b/extensions/ExampleSquareTrackerExtension/build.xml new file mode 100644 index 0000000..ec4a616 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project ExampleSquareTrackerExtension. + + + diff --git a/extensions/ExampleSquareTrackerExtension/lib/SmartDashboard.jar b/extensions/ExampleSquareTrackerExtension/lib/SmartDashboard.jar new file mode 120000 index 0000000..5e4bb39 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/SmartDashboard.jar @@ -0,0 +1 @@ +../../../../wpilib/tools/SmartDashboard.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCV.jar b/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCV.jar new file mode 120000 index 0000000..8e0d6df --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCV.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/dist/WPIJavaCV.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCVVideoExtension.jar b/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCVVideoExtension.jar new file mode 120000 index 0000000..a8bc1b6 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/WPIJavaCVVideoExtension.jar @@ -0,0 +1 @@ +../../WPIJavaCVVideoExtension/dist/WPIJavaCVVideoExtension.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/lib/javacpp.jar b/extensions/ExampleSquareTrackerExtension/lib/javacpp.jar new file mode 120000 index 0000000..b13cc4d --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/javacpp.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacpp.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/lib/javacv-windows-x86.jar b/extensions/ExampleSquareTrackerExtension/lib/javacv-windows-x86.jar new file mode 120000 index 0000000..438dd95 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/javacv-windows-x86.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacv-windows-x86.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/lib/javacv.jar b/extensions/ExampleSquareTrackerExtension/lib/javacv.jar new file mode 120000 index 0000000..06ad26d --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/lib/javacv.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacv.jar \ No newline at end of file diff --git a/extensions/ExampleSquareTrackerExtension/manifest.mf b/extensions/ExampleSquareTrackerExtension/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/build-impl.xml b/extensions/ExampleSquareTrackerExtension/nbproject/build-impl.xml new file mode 100644 index 0000000..5a9f0e1 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/build-impl.xml @@ -0,0 +1,1400 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/genfiles.properties b/extensions/ExampleSquareTrackerExtension/nbproject/genfiles.properties new file mode 100644 index 0000000..b58eb40 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0e31bf96 +build.xml.script.CRC32=fe93e624 +build.xml.stylesheet.CRC32=28e38971@1.38.3.45 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=0e31bf96 +nbproject/build-impl.xml.script.CRC32=1f2b204c +nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/private/config.properties b/extensions/ExampleSquareTrackerExtension/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/private/private.properties b/extensions/ExampleSquareTrackerExtension/nbproject/private/private.properties new file mode 100644 index 0000000..7b67f1f --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=false +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\Paul\\.netbeans\\6.9\\build.properties diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/private/private.xml b/extensions/ExampleSquareTrackerExtension/nbproject/private/private.xml new file mode 100644 index 0000000..cc2c0e5 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/project.properties b/extensions/ExampleSquareTrackerExtension/nbproject/project.properties new file mode 100644 index 0000000..59422cf --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/project.properties @@ -0,0 +1,87 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=ExampleSquareTrackerExtension +application.vendor=Greg +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ExampleSquareTrackerExtension.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.javacpp.jar=lib/javacpp.jar +file.reference.javacv-windows-x86.jar=lib/javacv-windows-x86.jar +file.reference.javacv.jar=lib/javacv.jar +file.reference.NetworkTable_Client.jar=lib/NetworkTable_Client.jar +file.reference.SmartDashboard.jar=lib/SmartDashboard.jar +file.reference.WPIJavaCVVideoExtension.jar=lib/WPIJavaCVVideoExtension.jar +file.reference.WPIJavaCV.jar=lib/WPIJavaCV.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.WPIJavaCV.jar}:\ + ${file.reference.WPIJavaCVVideoExtension.jar}:\ + ${file.reference.SmartDashboard.jar}:\ + ${file.reference.NetworkTable_Client.jar}:\ + ${file.reference.javacpp.jar}:\ + ${file.reference.javacv-windows-x86.jar}:\ + ${file.reference.javacv.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=squaretrackerextension.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/extensions/ExampleSquareTrackerExtension/nbproject/project.xml b/extensions/ExampleSquareTrackerExtension/nbproject/project.xml new file mode 100644 index 0000000..ead182e --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/nbproject/project.xml @@ -0,0 +1,49 @@ + + + org.netbeans.modules.java.j2seproject + + + ExampleSquareTrackerExtension + + + + + + + + + + NetworkTable_Client + jar + + jar + clean + jar + + + SmartDashboard + jar + + jar + clean + jar + + + WPICameraExtension + jar + + jar + clean + jar + + + WPIJavaCV + jar + + jar + clean + jar + + + + diff --git a/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/Square.pdf b/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/Square.pdf new file mode 100644 index 0000000..23cb55e Binary files /dev/null and b/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/Square.pdf differ diff --git a/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/SquareTrackerExtension.java b/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/SquareTrackerExtension.java new file mode 100644 index 0000000..a9361d3 --- /dev/null +++ b/extensions/ExampleSquareTrackerExtension/src/edu/wpi/first/smartdashboard/extensions/squaretracker/SquareTrackerExtension.java @@ -0,0 +1,119 @@ +package edu.wpi.first.smartdashboard.extensions.squaretracker; + +import edu.wpi.first.smartdashboard.extensions.wpijavacvvideo.LaptopCameraExtension; +import edu.wpi.first.smartdashboard.robot.Robot; +import edu.wpi.first.wpijavacv.WPIBinaryImage; +import edu.wpi.first.wpijavacv.WPIColor; +import edu.wpi.first.wpijavacv.WPIColorImage; +import edu.wpi.first.wpijavacv.WPIContour; +import edu.wpi.first.wpijavacv.WPIImage; +import edu.wpi.first.wpijavacv.WPIPoint; +import edu.wpi.first.wpijavacv.WPIPolygon; +import edu.wpi.first.wpilibj.networking.NetworkTable; +import java.util.ArrayList; + +/** + * + * @author Greg Granito + */ +public class SquareTrackerExtension extends LaptopCameraExtension { + public static final String NAME = "Laptop Camera Square Tracker"; + + /* Uses the table to send information from the DS to the robot */ + NetworkTable table = NetworkTable.getTable("camera"); + WPIColor targetColor = new WPIColor(255, 0, 0); + + @Override + public WPIImage processImage(WPIColorImage rawImage) { + + WPIBinaryImage blueBin = rawImage.getBlueChannel().getThresholdInverted(60); + WPIBinaryImage greenBin = rawImage.getGreenChannel().getThresholdInverted(60); + WPIBinaryImage redBin = rawImage.getRedChannel().getThresholdInverted(60); + + WPIBinaryImage finalBin = blueBin.getAnd(redBin).getAnd(greenBin); + + finalBin.erode(2); + finalBin.dilate(6); + + WPIContour[] contours = finalBin.findContours(); + + ArrayList polygons = new ArrayList(); + + for(WPIContour c : contours){ + double ratio = ((double)c.getHeight()) / ((double)c.getWidth()); + if(ratio < 1.5 && ratio> 0.75){ + polygons.add(c.approxPolygon(45)); + } + } + + ArrayList possiblePolygons = new ArrayList(); + + for(WPIPolygon p : polygons){ + if(p.isConvex() && p.getNumVertices() == 4){ + possiblePolygons.add(p); + }else{ + rawImage.drawPolygon(p, WPIColor.CYAN, 5); + } + } + + WPIPolygon square = null; + int squareArea = 0; + + for(WPIPolygon p : possiblePolygons){ + rawImage.drawPolygon(p, WPIColor.GREEN, 5); + for(WPIPolygon q : possiblePolygons){ + if(p == q) continue; + + int pCenterX = (p.getX() + (p.getWidth()/2)); + + int qCenterX = q.getX() + (q.getWidth()/2); + + int pCenterY = (p.getY() + (p.getHeight()/2)); + + int qCenterY = q.getY() + (q.getHeight()/2); + + rawImage.drawPoint(new WPIPoint(pCenterX, pCenterY), targetColor, 5); + rawImage.drawPoint(new WPIPoint(qCenterX, qCenterY), targetColor, 5); + + if(Math.abs(pCenterX - qCenterX) < 20 && + Math.abs(pCenterY - qCenterY) < 20){ + int pArea = Math.abs(p.getArea()); + int qArea = Math.abs(q.getArea()); + if(pArea > qArea){ + square = p; + squareArea = pArea; + }else{ + square = q; + squareArea = qArea; + } + break; + } + } + } + + if(square != null){ + double x = square.getX() + (square.getWidth()/2); + x = (2 * (x/rawImage.getWidth())) - 1; + + double area = ((double)squareArea) / ((double)(rawImage.getWidth() * rawImage.getHeight())); + + synchronized(table) { + table.beginTransaction(); + table.putBoolean("found", true); + table.putDouble("x", x); + table.putDouble("area", area); + table.endTransaction(); + } + + Robot.getTable().putBoolean("found", true); + Robot.getTable().putDouble("X", x); + Robot.getTable().putDouble("Area", area); + rawImage.drawPolygon(square, targetColor, 7); + }else{ + table.putBoolean("found", false); + Robot.getTable().putBoolean("found", false); + } + + return rawImage; + } +} diff --git a/extensions/WPIJavaCVVideoExtension/build.xml b/extensions/WPIJavaCVVideoExtension/build.xml new file mode 100644 index 0000000..27d6203 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + Builds, tests, and runs the project WPIJavaCVVideoExtension. + + + diff --git a/extensions/WPIJavaCVVideoExtension/lib/SmartDashboard.jar b/extensions/WPIJavaCVVideoExtension/lib/SmartDashboard.jar new file mode 120000 index 0000000..5e4bb39 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/lib/SmartDashboard.jar @@ -0,0 +1 @@ +../../../../wpilib/tools/SmartDashboard.jar \ No newline at end of file diff --git a/extensions/WPIJavaCVVideoExtension/lib/WPIJavaCV.jar b/extensions/WPIJavaCVVideoExtension/lib/WPIJavaCV.jar new file mode 120000 index 0000000..8e0d6df --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/lib/WPIJavaCV.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/dist/WPIJavaCV.jar \ No newline at end of file diff --git a/extensions/WPIJavaCVVideoExtension/lib/javacpp.jar b/extensions/WPIJavaCVVideoExtension/lib/javacpp.jar new file mode 120000 index 0000000..b13cc4d --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/lib/javacpp.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacpp.jar \ No newline at end of file diff --git a/extensions/WPIJavaCVVideoExtension/lib/javacv-windows-x86.jar b/extensions/WPIJavaCVVideoExtension/lib/javacv-windows-x86.jar new file mode 120000 index 0000000..438dd95 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/lib/javacv-windows-x86.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacv-windows-x86.jar \ No newline at end of file diff --git a/extensions/WPIJavaCVVideoExtension/lib/javacv.jar b/extensions/WPIJavaCVVideoExtension/lib/javacv.jar new file mode 120000 index 0000000..06ad26d --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/lib/javacv.jar @@ -0,0 +1 @@ +../../../WPIJavaCV/lib/javacv.jar \ No newline at end of file diff --git a/extensions/WPIJavaCVVideoExtension/manifest.mf b/extensions/WPIJavaCVVideoExtension/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/build-impl.xml b/extensions/WPIJavaCVVideoExtension/nbproject/build-impl.xml new file mode 100644 index 0000000..e46d053 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/build-impl.xml @@ -0,0 +1,1400 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/genfiles.properties b/extensions/WPIJavaCVVideoExtension/nbproject/genfiles.properties new file mode 100644 index 0000000..35733b3 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=0d2b3442 +build.xml.script.CRC32=f9e70049 +build.xml.stylesheet.CRC32=28e38971@1.53.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=0d2b3442 +nbproject/build-impl.xml.script.CRC32=55f5fbcf +nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/private/config.properties b/extensions/WPIJavaCVVideoExtension/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/private/private.properties b/extensions/WPIJavaCVVideoExtension/nbproject/private/private.properties new file mode 100644 index 0000000..bb21662 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=false +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +user.properties.file=C:\\Users\\Mitchell Wills\\AppData\\Roaming\\NetBeans\\7.2\\build.properties diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/private/private.xml b/extensions/WPIJavaCVVideoExtension/nbproject/private/private.xml new file mode 100644 index 0000000..cc2c0e5 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/project.properties b/extensions/WPIJavaCVVideoExtension/nbproject/project.properties new file mode 100644 index 0000000..7459bfb --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/project.properties @@ -0,0 +1,96 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=WPIJavaCVVideoExtension +application.vendor=Greg +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/WPIJavaCVVideoExtension.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.javacpp.jar=lib/javacpp.jar +file.reference.javacv-windows-x86.jar=lib/javacv-windows-x86.jar +file.reference.javacv.jar=lib/javacv.jar +file.reference.SmartDashboard.jar=lib/SmartDashboard.jar +file.reference.WPIJavaCV.jar=lib/WPIJavaCV.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.WPIJavaCV.jar}:\ + ${file.reference.SmartDashboard.jar}:\ + ${file.reference.javacpp.jar}:\ + ${file.reference.javacv-windows-x86.jar}:\ + ${file.reference.javacv.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +main.class= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/extensions/WPIJavaCVVideoExtension/nbproject/project.xml b/extensions/WPIJavaCVVideoExtension/nbproject/project.xml new file mode 100644 index 0000000..32fd950 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/nbproject/project.xml @@ -0,0 +1,16 @@ + + + org.netbeans.modules.java.j2seproject + + + WPIJavaCVVideoExtension + + + + + + + + + + diff --git a/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AbstractVideoExtension.java b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AbstractVideoExtension.java new file mode 100644 index 0000000..9324232 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AbstractVideoExtension.java @@ -0,0 +1,166 @@ +package edu.wpi.first.smartdashboard.extensions.wpijavacvvideo; + +import edu.wpi.first.smartdashboard.gui.DashboardPrefs; +import edu.wpi.first.smartdashboard.gui.StaticWidget; +import edu.wpi.first.smartdashboard.properties.Property; +import edu.wpi.first.smartdashboard.properties.StringProperty; +import edu.wpi.first.wpijavacv.WPIColorImage; +import edu.wpi.first.wpijavacv.WPIFFmpegVideo; +import edu.wpi.first.wpijavacv.WPIGrayscaleImage; +import edu.wpi.first.wpijavacv.WPIImage; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.image.BufferedImage; + +/** + * An extension that displays a video. + * + * @author Greg Granito + * @author Luke Shumaker + */ +public abstract class AbstractVideoExtension extends StaticWidget { + public static final String NAME = null; + protected static final long errorBackoff = -1; + abstract protected Video getVideo(); + abstract protected boolean isVideoProperty(Property property); + + private boolean connected = false; + + public class GCThread extends Thread { + + boolean destroyed = false; + + @Override + public void run() { + while (!destroyed) { + try { + Thread.sleep(10000); + } catch (InterruptedException ex) { + } + System.gc(); + } + } + + public void destroy() { + destroyed = true; + interrupt(); + } + } + + public class BGThread extends Thread { + + boolean destroyed = false; + + public BGThread() { + super(NAME+" Background"); + } + + @Override + public void run() { + WPIImage image; + while (!destroyed) { + if (vid == null) { + vid = getVideo(); + } + try { + image = vid.getImage(); + + if (image instanceof WPIColorImage) { + drawnImage = processImage((WPIColorImage) image).getBufferedImage(); + } else if (image instanceof WPIGrayscaleImage) { + drawnImage = processImage((WPIGrayscaleImage) image).getBufferedImage(); + } + + repaint(); + } catch (final Exception e) { + e.printStackTrace(); + vid.dispose(); + vid = null; + drawnImage = null; + repaint(); + try { + Thread.sleep(errorBackoff); + } catch (InterruptedException ex) { + } + } + } + + } + + @Override + public void destroy() { + destroyed = true; + } + } + private boolean resized = false; + private Video vid; + private BufferedImage drawnImage; + private BGThread bgThread = new BGThread(); + private GCThread gcThread = new GCThread(); + + @Override + public void init() { + setPreferredSize(new Dimension(100, 100)); + bgThread.start(); + gcThread.start(); + revalidate(); + repaint(); + } + + @Override + public void propertyChanged(Property property) { + if (isVideoProperty(property)) { + if (vid != null) { + vid.dispose(); + } + try { + vid = getVideo(); + } catch (Exception e) { + e.printStackTrace(); + drawnImage = null; + setPreferredSize(new Dimension(100, 100)); + revalidate(); + repaint(); + } + } + + } + + @Override + public void disconnect() { + bgThread.destroy(); + gcThread.destroy(); + if(vid != null) vid.dispose(); + super.disconnect(); + } + + @Override + protected void paintComponent(Graphics g) { + if (drawnImage != null) { + if (!resized) { + setPreferredSize(new Dimension(drawnImage.getWidth(), drawnImage.getHeight())); + revalidate(); + } + int width = getBounds().width; + int height = getBounds().height; + double scale = Math.min((double) width / (double) drawnImage.getWidth(), (double) height / (double) drawnImage.getHeight()); + g.drawImage(drawnImage, (int) (width - (scale * drawnImage.getWidth())) / 2, (int) (height - (scale * drawnImage.getHeight())) / 2, + (int) ((width + scale * drawnImage.getWidth()) / 2), (int) (height + scale * drawnImage.getHeight()) / 2, + 0, 0, drawnImage.getWidth(), drawnImage.getHeight(), null); + } else { + g.setColor(Color.PINK); + g.fillRect(0, 0, getBounds().width, getBounds().height); + g.setColor(Color.BLACK); + g.drawString("NO CONNECTION", 10, 10); + } + } + + public WPIImage processImage(WPIColorImage rawImage) { + return rawImage; + } + + public WPIImage processImage(WPIGrayscaleImage rawImage) { + return rawImage; + } +} diff --git a/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AxisCameraExtension.java b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AxisCameraExtension.java new file mode 100644 index 0000000..6851dfc --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/AxisCameraExtension.java @@ -0,0 +1,51 @@ +package edu.wpi.first.smartdashboard.extensions.wpijavacvvideo; + +import edu.wpi.first.smartdashboard.gui.DashboardPrefs; +import edu.wpi.first.smartdashboard.properties.IPAddressProperty; +import edu.wpi.first.smartdashboard.properties.Property; +import edu.wpi.first.wpijavacv.WPICamera; +import edu.wpi.first.wpijavacv.WPIImage; + +/** + * Exactly like VideoURLExtension, except it forces the Stream URL + * to be of the form "http://${IP_address}/mjpg/video.mjpg" and only + * lets the user configure the IP address. + * + * @author Greg Granito + */ +public class AxisCameraExtension extends AbstractVideoExtension { + public static final String NAME = "Axis Camera"; + protected static final long errorBackoff = 2000; + + @Override + protected Video getVideo() { + return new Camera(new WPICamera(ipProperty.getSaveValue()), 5.0); + } + + @Override + protected boolean isVideoProperty(Property property) { + return property == ipProperty; + } + + public final IPAddressProperty ipProperty = new IPAddressProperty(this, "Axis Camera IP Address", defaultIPaddress()); + + private final int[] defaultIPaddress() { + final int team = DashboardPrefs.getInstance().team.getValue(); + return new int[]{10, team / 100, team % 100, 11}; + } + + public class Camera implements Video { + private final WPICamera vid; + private final double timeout; + public Camera(WPICamera vid, double timeout){ + this.vid = vid; + this.timeout = timeout; + } + public WPIImage getImage() throws Exception { + return vid.getNewImage(timeout); + } + public void dispose() { + vid.dispose(); + } + } +} diff --git a/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/LaptopCameraExtension.java b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/LaptopCameraExtension.java new file mode 100644 index 0000000..03fa943 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/LaptopCameraExtension.java @@ -0,0 +1,39 @@ +package edu.wpi.first.smartdashboard.extensions.wpijavacvvideo; + +import edu.wpi.first.smartdashboard.properties.Property; +import edu.wpi.first.wpijavacv.WPIImage; +import edu.wpi.first.wpijavacv.WPILaptopCamera; + +/** + * An extension that displays the laptop built-in camera. + * + * @author Greg Granito + * @author Luke Shumaker + */ +public class LaptopCameraExtension extends AbstractVideoExtension { + public static final String NAME = "Laptop Camera"; + protected static final long errorBackoff = 500; + + @Override + protected Video getVideo() { + return new Camera(new WPILaptopCamera()); + } + + @Override + protected boolean isVideoProperty(Property property) { + return false; + } + + public class Camera implements Video { + private final WPILaptopCamera vid; + public Camera(WPILaptopCamera vid){ + this.vid = vid; + } + public WPIImage getImage() { + return vid.getCurrentFrame(); + } + public void dispose() { + vid.dispose(); + } + } +} diff --git a/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/Video.java b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/Video.java new file mode 100644 index 0000000..8187701 --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/Video.java @@ -0,0 +1,13 @@ +package edu.wpi.first.smartdashboard.extensions.wpijavacvvideo; + +import edu.wpi.first.wpijavacv.WPIImage; + +/** + * The basics of what you need out of a video source. + * + * @author Luke Shumaker + */ +public interface Video { + public WPIImage getImage() throws Exception; + public void dispose(); +} diff --git a/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/VideoURLExtension.java b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/VideoURLExtension.java new file mode 100644 index 0000000..bbe4d6b --- /dev/null +++ b/extensions/WPIJavaCVVideoExtension/src/edu/wpi/first/smartdashboard/extensions/wpijavacvvideo/VideoURLExtension.java @@ -0,0 +1,50 @@ +package edu.wpi.first.smartdashboard.extensions.wpijavacvvideo; + +import edu.wpi.first.smartdashboard.gui.DashboardPrefs; +import edu.wpi.first.smartdashboard.properties.Property; +import edu.wpi.first.smartdashboard.properties.StringProperty; +import edu.wpi.first.wpijavacv.WPIFFmpegVideo; +import edu.wpi.first.wpijavacv.WPIImage; + +/** + * An extension that takes a video stream URL and displays the video. + * + * @author Greg Granito + * @author Luke Shumaker + */ +public class VideoURLExtension extends AbstractVideoExtension { + public static final String NAME = "Video URL Stream"; + protected static final long errorBackoff = 2000; + + @Override + protected Video getVideo() { + return new Camera(new WPIFFmpegVideo(pathProperty.getSaveValue()), 5.0); + } + + @Override + protected boolean isVideoProperty(Property property) { + return property == pathProperty; + } + + public final StringProperty pathProperty = new StringProperty(this, "Video Path", defaultVideoPath()); + + private static String defaultVideoPath() { + final int team = DashboardPrefs.getInstance().team.getValue(); + return "http://10." + (team / 100) + "." + (team % 100) + ".11/mjpg/video.mjpg"; + } + + public class Camera implements Video { + private final WPIFFmpegVideo vid; + private final double timeout; + public Camera(WPIFFmpegVideo vid, double timeout){ + this.vid = vid; + this.timeout = timeout; + } + public WPIImage getImage() throws Exception { + return vid.getNewImage(timeout); + } + public void dispose() { + vid.dispose(); + } + } +} diff --git a/extensions/camera/SquareTracker/Square.pdf b/extensions/camera/SquareTracker/Square.pdf deleted file mode 100644 index 23cb55e..0000000 Binary files a/extensions/camera/SquareTracker/Square.pdf and /dev/null differ diff --git a/extensions/camera/SquareTracker/build.xml b/extensions/camera/SquareTracker/build.xml deleted file mode 100644 index 90c2964..0000000 --- a/extensions/camera/SquareTracker/build.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project SquareTrackerExtension. - - - diff --git a/extensions/camera/SquareTracker/manifest.mf b/extensions/camera/SquareTracker/manifest.mf deleted file mode 100644 index 1574df4..0000000 --- a/extensions/camera/SquareTracker/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/extensions/camera/SquareTracker/nbproject/build-impl.xml b/extensions/camera/SquareTracker/nbproject/build-impl.xml deleted file mode 100644 index 99dd2f9..0000000 --- a/extensions/camera/SquareTracker/nbproject/build-impl.xml +++ /dev/null @@ -1,950 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/camera/SquareTracker/nbproject/genfiles.properties b/extensions/camera/SquareTracker/nbproject/genfiles.properties deleted file mode 100644 index b58eb40..0000000 --- a/extensions/camera/SquareTracker/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=0e31bf96 -build.xml.script.CRC32=fe93e624 -build.xml.stylesheet.CRC32=28e38971@1.38.3.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0e31bf96 -nbproject/build-impl.xml.script.CRC32=1f2b204c -nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 diff --git a/extensions/camera/SquareTracker/nbproject/private/config.properties b/extensions/camera/SquareTracker/nbproject/private/config.properties deleted file mode 100644 index e69de29..0000000 diff --git a/extensions/camera/SquareTracker/nbproject/private/private.properties b/extensions/camera/SquareTracker/nbproject/private/private.properties deleted file mode 100644 index 7b67f1f..0000000 --- a/extensions/camera/SquareTracker/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=false -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\Paul\\.netbeans\\6.9\\build.properties diff --git a/extensions/camera/SquareTracker/nbproject/private/private.xml b/extensions/camera/SquareTracker/nbproject/private/private.xml deleted file mode 100644 index cc2c0e5..0000000 --- a/extensions/camera/SquareTracker/nbproject/private/private.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/extensions/camera/SquareTracker/nbproject/project.properties b/extensions/camera/SquareTracker/nbproject/project.properties deleted file mode 100644 index c9b6617..0000000 --- a/extensions/camera/SquareTracker/nbproject/project.properties +++ /dev/null @@ -1,91 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=SquareTrackerExtension -application.vendor=Greg -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/SquareTrackerExtension.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.javacpp.jar=../../../WPIJavaCV/lib/javacpp.jar -file.reference.javacv-windows-x86.jar=../../../WPIJavaCV/lib/javacv-windows-x86.jar -file.reference.javacv.jar=../../../WPIJavaCV/lib/javacv.jar -includes=** -jar.compress=false -javac.classpath=\ - ${reference.WPIJavaCV.jar}:\ - ${reference.WPICameraExtension.jar}:\ - ${reference.SmartDashboard.jar}:\ - ${reference.NetworkTable_Client.jar}:\ - ${file.reference.javacpp.jar}:\ - ${file.reference.javacv-windows-x86.jar}:\ - ${file.reference.javacv.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.5 -javac.target=1.5 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=squaretrackerextension.Main -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -platform.active=default_platform -project.NetworkTable_Client=../../../NetworkTable/Client/Java/trunk -project.SmartDashboard=../../../smartdashboard -project.WPICameraExtension=../WPICameraExtension -project.WPIJavaCV=../../../WPIJavaCV -reference.NetworkTable_Client.jar=${project.NetworkTable_Client}/dist/NetworkTable_Client.jar -reference.SmartDashboard.jar=${project.SmartDashboard}/dist/SmartDashboard.jar -reference.WPICameraExtension.jar=${project.WPICameraExtension}/dist/WPICameraExtension.jar -reference.WPIJavaCV.jar=${project.WPIJavaCV}/dist/WPIJavaCV.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/extensions/camera/SquareTracker/nbproject/project.xml b/extensions/camera/SquareTracker/nbproject/project.xml deleted file mode 100644 index a69eeae..0000000 --- a/extensions/camera/SquareTracker/nbproject/project.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - SquareTrackerExtension - - - - - - - - - - NetworkTable_Client - jar - - jar - clean - jar - - - SmartDashboard - jar - - jar - clean - jar - - - WPICameraExtension - jar - - jar - clean - jar - - - WPIJavaCV - jar - - jar - clean - jar - - - - diff --git a/extensions/camera/SquareTracker/src/edu/wpi/first/wpilibj/examples/SquareTrackerExtension.java b/extensions/camera/SquareTracker/src/edu/wpi/first/wpilibj/examples/SquareTrackerExtension.java deleted file mode 100644 index e5886a2..0000000 --- a/extensions/camera/SquareTracker/src/edu/wpi/first/wpilibj/examples/SquareTrackerExtension.java +++ /dev/null @@ -1,118 +0,0 @@ -package edu.wpi.first.wpilibj.examples; - -import edu.wpi.first.smartdashboard.camera.WPILaptopCameraExtension; -import edu.wpi.first.smartdashboard.robot.Robot; -import edu.wpi.first.wpijavacv.WPIBinaryImage; -import edu.wpi.first.wpijavacv.WPIColor; -import edu.wpi.first.wpijavacv.WPIColorImage; -import edu.wpi.first.wpijavacv.WPIContour; -import edu.wpi.first.wpijavacv.WPIImage; -import edu.wpi.first.wpijavacv.WPIPoint; -import edu.wpi.first.wpijavacv.WPIPolygon; -import edu.wpi.first.wpilibj.networking.NetworkTable; -import java.util.ArrayList; - -/** - * - * @author Greg Granito - */ -public class SquareTrackerExtension extends WPILaptopCameraExtension { - public static final String NAME = "Laptop Camera Square Tracker"; - - NetworkTable table = NetworkTable.getTable("camera"); - WPIColor targetColor = new WPIColor(255, 0, 0); - - @Override - public WPIImage processImage(WPIColorImage rawImage) { - - WPIBinaryImage blueBin = rawImage.getBlueChannel().getThresholdInverted(60); - WPIBinaryImage greenBin = rawImage.getGreenChannel().getThresholdInverted(60); - WPIBinaryImage redBin = rawImage.getRedChannel().getThresholdInverted(60); - - WPIBinaryImage finalBin = blueBin.getAnd(redBin).getAnd(greenBin); - - finalBin.erode(2); - finalBin.dilate(6); - - WPIContour[] contours = finalBin.findContours(); - - ArrayList polygons = new ArrayList(); - - for(WPIContour c : contours){ - double ratio = ((double)c.getHeight()) / ((double)c.getWidth()); - if(ratio < 1.5 && ratio> 0.75){ - polygons.add(c.approxPolygon(45)); - } - } - - ArrayList possiblePolygons = new ArrayList(); - - for(WPIPolygon p : polygons){ - if(p.isConvex() && p.getNumVertices() == 4){ - possiblePolygons.add(p); - }else{ - rawImage.drawPolygon(p, WPIColor.CYAN, 5); - } - } - - WPIPolygon square = null; - int squareArea = 0; - - for(WPIPolygon p : possiblePolygons){ - rawImage.drawPolygon(p, WPIColor.GREEN, 5); - for(WPIPolygon q : possiblePolygons){ - if(p == q) continue; - - int pCenterX = (p.getX() + (p.getWidth()/2)); - - int qCenterX = q.getX() + (q.getWidth()/2); - - int pCenterY = (p.getY() + (p.getHeight()/2)); - - int qCenterY = q.getY() + (q.getHeight()/2); - - rawImage.drawPoint(new WPIPoint(pCenterX, pCenterY), targetColor, 5); - rawImage.drawPoint(new WPIPoint(qCenterX, qCenterY), targetColor, 5); - - if(Math.abs(pCenterX - qCenterX) < 20 && - Math.abs(pCenterY - qCenterY) < 20){ - int pArea = Math.abs(p.getArea()); - int qArea = Math.abs(q.getArea()); - if(pArea > qArea){ - square = p; - squareArea = pArea; - }else{ - square = q; - squareArea = qArea; - } - break; - } - } - } - - if(square != null){ - double x = square.getX() + (square.getWidth()/2); - x = (2 * (x/rawImage.getWidth())) - 1; - - double area = ((double)squareArea) / ((double)(rawImage.getWidth() * rawImage.getHeight())); - - synchronized(table) { - table.beginTransaction(); - table.putBoolean("found", true); - table.putDouble("x", x); - table.putDouble("area", area); - table.endTransaction(); - } - - Robot.getTable().putBoolean("found", true); - Robot.getTable().putDouble("X", x); - Robot.getTable().putDouble("Area", area); - rawImage.drawPolygon(square, targetColor, 7); - }else{ - table.putBoolean("found", false); - Robot.getTable().putBoolean("found", false); - } - - return rawImage; - } -} diff --git a/extensions/camera/WPICameraExtension/build.xml b/extensions/camera/WPICameraExtension/build.xml deleted file mode 100644 index 5ca1581..0000000 --- a/extensions/camera/WPICameraExtension/build.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project WPICameraExtension. - - - diff --git a/extensions/camera/WPICameraExtension/manifest.mf b/extensions/camera/WPICameraExtension/manifest.mf deleted file mode 100644 index 1574df4..0000000 --- a/extensions/camera/WPICameraExtension/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/extensions/camera/WPICameraExtension/nbproject/build-impl.xml b/extensions/camera/WPICameraExtension/nbproject/build-impl.xml deleted file mode 100644 index ea6d3b7..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/build-impl.xml +++ /dev/null @@ -1,1400 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/camera/WPICameraExtension/nbproject/genfiles.properties b/extensions/camera/WPICameraExtension/nbproject/genfiles.properties deleted file mode 100644 index 35733b3..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=0d2b3442 -build.xml.script.CRC32=f9e70049 -build.xml.stylesheet.CRC32=28e38971@1.53.1.46 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0d2b3442 -nbproject/build-impl.xml.script.CRC32=55f5fbcf -nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/extensions/camera/WPICameraExtension/nbproject/private/config.properties b/extensions/camera/WPICameraExtension/nbproject/private/config.properties deleted file mode 100644 index e69de29..0000000 diff --git a/extensions/camera/WPICameraExtension/nbproject/private/private.properties b/extensions/camera/WPICameraExtension/nbproject/private/private.properties deleted file mode 100644 index bb21662..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=false -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\Mitchell Wills\\AppData\\Roaming\\NetBeans\\7.2\\build.properties diff --git a/extensions/camera/WPICameraExtension/nbproject/private/private.xml b/extensions/camera/WPICameraExtension/nbproject/private/private.xml deleted file mode 100644 index cc2c0e5..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/private/private.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/extensions/camera/WPICameraExtension/nbproject/project.properties b/extensions/camera/WPICameraExtension/nbproject/project.properties deleted file mode 100644 index 5cfab74..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/project.properties +++ /dev/null @@ -1,96 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=WPICameraExtension -application.vendor=Greg -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/WPICameraExtension.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.javacpp.jar=lib/javacpp.jar -file.reference.javacv-windows-x86.jar=lib/javacv-windows-x86.jar -file.reference.javacv.jar=lib/javacv.jar -file.reference.SmartDashboard.jar=lib/SmartDashboard.jar -file.reference.WPIJavaCV.jar=lib/WPIJavaCV.jar -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -javac.classpath=\ - ${file.reference.WPIJavaCV.jar}:\ - ${file.reference.SmartDashboard.jar}:\ - ${file.reference.javacpp.jar}:\ - ${file.reference.javacv-windows-x86.jar}:\ - ${file.reference.javacv.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.5 -javac.target=1.5 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath}:\ - ${libs.junit_4.classpath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -main.class= -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/extensions/camera/WPICameraExtension/nbproject/project.xml b/extensions/camera/WPICameraExtension/nbproject/project.xml deleted file mode 100644 index 41107a0..0000000 --- a/extensions/camera/WPICameraExtension/nbproject/project.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - WPICameraExtension - - - - - - - - - - diff --git a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamExtension.java b/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamExtension.java deleted file mode 100644 index 6937b86..0000000 --- a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamExtension.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.smartdashboard.camera; - -import edu.wpi.first.smartdashboard.gui.StaticWidget; -import edu.wpi.first.smartdashboard.properties.Property; -import edu.wpi.first.smartdashboard.properties.StringProperty; -import edu.wpi.first.wpijavacv.WPIColorImage; -import edu.wpi.first.wpijavacv.WPIFFmpegVideo; -import edu.wpi.first.wpijavacv.WPIGrayscaleImage; -import edu.wpi.first.wpijavacv.WPIImage; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; - -/** - * - * @author Greg Granito - */ -public class VideoStreamExtension extends StaticWidget { - - public static final String NAME = "Video Stream"; - private boolean connected = false; - - public class GCThread extends Thread { - - boolean destroyed = false; - - @Override - public void run() { - while (!destroyed) { - try { - Thread.sleep(10000); - } catch (InterruptedException ex) { - } - System.gc(); - } - } - - public void destroy() { - destroyed = true; - interrupt(); - } - } - - public class BGThread extends Thread { - - boolean destroyed = false; - - public BGThread() { - super("Video Stream Background"); - } - - @Override - public void run() { - WPIImage image; - while (!destroyed) { - if (cam == null) { - cam = new WPIFFmpegVideo(pathProperty.getSaveValue()); - } - try { - image = cam.getNewImage(5.0); - - if (image instanceof WPIColorImage) { - drawnImage = processImage((WPIColorImage) image).getBufferedImage(); - repaint(); - - } else if (image instanceof WPIGrayscaleImage) { - drawnImage = processImage((WPIGrayscaleImage) image).getBufferedImage(); - repaint(); - } - } catch (final Exception e) { - e.printStackTrace(); - cam.dispose(); - cam = null; - drawnImage = null; - repaint(); - try { - Thread.sleep(2000); - } catch (InterruptedException ex) { - } - } - } - - } - - @Override - public void destroy() { - destroyed = true; - } - } - private boolean resized = false; - private WPIFFmpegVideo cam; - private BufferedImage drawnImage; - private BGThread bgThread = new BGThread(); - private GCThread gcThread = new GCThread(); - public final StringProperty pathProperty = new StringProperty(this, "Video Path", "http://localhost:8080/something"); - - @Override - public void init() { - setPreferredSize(new Dimension(100, 100)); - bgThread.start(); - gcThread.start(); - revalidate(); - repaint(); - } - - @Override - public void propertyChanged(Property property) { - if (property == pathProperty) { - if (cam != null) { - cam.dispose(); - } - try { - cam = new WPIFFmpegVideo(pathProperty.getSaveValue()); - } catch (Exception e) { - e.printStackTrace(); - drawnImage = null; - setPreferredSize(new Dimension(100, 100)); - revalidate(); - repaint(); - } - } - - } - - @Override - public void disconnect() { - bgThread.destroy(); - gcThread.destroy(); - if(cam != null) cam.dispose(); - super.disconnect(); - } - - @Override - protected void paintComponent(Graphics g) { - if (drawnImage != null) { - if (!resized) { - setPreferredSize(new Dimension(drawnImage.getWidth(), drawnImage.getHeight())); - revalidate(); - } - int width = getBounds().width; - int height = getBounds().height; - double scale = Math.min((double) width / (double) drawnImage.getWidth(), (double) height / (double) drawnImage.getHeight()); - g.drawImage(drawnImage, (int) (width - (scale * drawnImage.getWidth())) / 2, (int) (height - (scale * drawnImage.getHeight())) / 2, - (int) ((width + scale * drawnImage.getWidth()) / 2), (int) (height + scale * drawnImage.getHeight()) / 2, - 0, 0, drawnImage.getWidth(), drawnImage.getHeight(), null); - } else { - g.setColor(Color.PINK); - g.fillRect(0, 0, getBounds().width, getBounds().height); - g.setColor(Color.BLACK); - g.drawString("NO CONNECTION", 10, 10); - } - } - - public WPIImage processImage(WPIColorImage rawImage) { - return rawImage; - } - - public WPIImage processImage(WPIGrayscaleImage rawImage) { - return rawImage; - } -} diff --git a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamViewerExtension.java b/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamViewerExtension.java deleted file mode 100644 index 86f55cc..0000000 --- a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/VideoStreamViewerExtension.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.smartdashboard.camera; - -import edu.wpi.first.smartdashboard.gui.DashboardPrefs; -import edu.wpi.first.smartdashboard.gui.StaticWidget; -import edu.wpi.first.smartdashboard.properties.Property; -import edu.wpi.first.smartdashboard.properties.StringProperty; -import edu.wpi.first.wpijavacv.WPIColorImage; -import edu.wpi.first.wpijavacv.WPIFFmpegVideo; -import edu.wpi.first.wpijavacv.WPIGrayscaleImage; -import edu.wpi.first.wpijavacv.WPIImage; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; - -/** - * - * @author Greg Granito - */ -public class VideoStreamViewerExtension extends StaticWidget { - - public static final String NAME = "Video Stream Viewer"; - private boolean connected = false; - - public class BGThread extends Thread { - - boolean destroyed = false; - - public BGThread() { - super("Video Stream Background"); - } - - @Override - public void run() { - WPIImage image; - while (!destroyed) { - if (cam == null) { - cam = new WPIFFmpegVideoViewer(pathProperty.getSaveValue()); - } - try { - drawnImage = cam.getNewImage(5.0); - repaint(); - - } catch (final Exception e) { - e.printStackTrace(); - cam.dispose(); - cam = null; - drawnImage = null; - repaint(); - try { - Thread.sleep(2000); - } catch (InterruptedException ex) { - } - } - } - - } - - @Override - public void destroy() { - destroyed = true; - } - } - private boolean resized = false; - private WPIFFmpegVideoViewer cam; - private BufferedImage drawnImage; - private BGThread bgThread = new BGThread(); - private final int team = DashboardPrefs.getInstance().team.getValue(); - public final StringProperty pathProperty = new StringProperty(this, "Video Path", "http://10." + (team / 100) + "." + (team % 100) + ".11/mjpg/video.mjpg"); - - @Override - public void init() { - setPreferredSize(new Dimension(100, 100)); - bgThread.start(); - revalidate(); - repaint(); - } - - @Override - public void propertyChanged(Property property) { - if (property == pathProperty) { - if (cam != null) { - cam.dispose(); - } - try { - cam = new WPIFFmpegVideoViewer(pathProperty.getSaveValue()); - } catch (Exception e) { - e.printStackTrace(); - drawnImage = null; - setPreferredSize(new Dimension(100, 100)); - revalidate(); - repaint(); - } - } - - } - - @Override - public void disconnect() { - bgThread.destroy(); - if(cam != null) cam.dispose(); - super.disconnect(); - } - - @Override - protected void paintComponent(Graphics g) { - if (drawnImage != null) { - if (!resized) { - setPreferredSize(new Dimension(drawnImage.getWidth(), drawnImage.getHeight())); - revalidate(); - } - int width = getBounds().width; - int height = getBounds().height; - double scale = Math.min((double) width / (double) drawnImage.getWidth(), (double) height / (double) drawnImage.getHeight()); - g.drawImage(drawnImage, (int) (width - (scale * drawnImage.getWidth())) / 2, (int) (height - (scale * drawnImage.getHeight())) / 2, - (int) ((width + scale * drawnImage.getWidth()) / 2), (int) (height + scale * drawnImage.getHeight()) / 2, - 0, 0, drawnImage.getWidth(), drawnImage.getHeight(), null); - } else { - g.setColor(Color.PINK); - g.fillRect(0, 0, getBounds().width, getBounds().height); - g.setColor(Color.BLACK); - g.drawString("NO CONNECTION", 10, 10); - } - } -} diff --git a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPICameraExtension.java b/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPICameraExtension.java deleted file mode 100644 index d10d633..0000000 --- a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPICameraExtension.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.smartdashboard.camera; - -import edu.wpi.first.smartdashboard.gui.DashboardFrame; -import edu.wpi.first.smartdashboard.gui.DashboardPrefs; -import edu.wpi.first.smartdashboard.gui.StaticWidget; -import edu.wpi.first.smartdashboard.properties.IPAddressProperty; -import edu.wpi.first.smartdashboard.properties.Property; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import javax.swing.SwingUtilities; -import edu.wpi.first.wpijavacv.WPICamera; -import edu.wpi.first.wpijavacv.WPIColorImage; -import edu.wpi.first.wpijavacv.WPIGrayscaleImage; -import edu.wpi.first.wpijavacv.WPIImage; - -/** - * - * @author Greg Granito - */ -public class WPICameraExtension extends StaticWidget { - - public static final String NAME = "Camera"; - private boolean connected = false; - - public class GCThread extends Thread { - - boolean destroyed = false; - - @Override - public void run() { - while (!destroyed) { - try { - Thread.sleep(10000); - } catch (InterruptedException ex) { - } - System.gc(); - } - } - - public void destroy() { - destroyed = true; - interrupt(); - } - } - - public class BGThread extends Thread { - - boolean destroyed = false; - - public BGThread() { - super("Camera Background"); - } - - @Override - public void run() { - WPIImage image; - while (!destroyed) { - if (cam == null) { - cam = new WPICamera(ipProperty.getSaveValue()); - } - try { - image = cam.getNewImage(5.0); - - if (image instanceof WPIColorImage) { - drawnImage = processImage((WPIColorImage) image).getBufferedImage(); - repaint(); - - } else if (image instanceof WPIGrayscaleImage) { - drawnImage = processImage((WPIGrayscaleImage) image).getBufferedImage(); - repaint(); - } - } catch (final Exception e) { - e.printStackTrace(); - cam.dispose(); - cam = null; - drawnImage = null; - repaint(); - try { - Thread.sleep(2000); - } catch (InterruptedException ex) { - } - } - } - - } - - @Override - public void destroy() { - destroyed = true; - } - } - private boolean resized = false; - private WPICamera cam; - private BufferedImage drawnImage; - private BGThread bgThread = new BGThread(); - private GCThread gcThread = new GCThread(); - public final IPAddressProperty ipProperty = new IPAddressProperty(this, "Camera IP Address", new int[]{10, (DashboardPrefs.getInstance().team.getValue() / 100), (DashboardPrefs.getInstance().team.getValue() % 100), 11}); - - @Override - public void init() { - setPreferredSize(new Dimension(100, 100)); - bgThread.start(); - gcThread.start(); - revalidate(); - repaint(); - } - - @Override - public void propertyChanged(Property property) { - if (property == ipProperty) { - if (cam != null) { - cam.dispose(); - } - try { - cam = new WPICamera(ipProperty.getSaveValue()); - } catch (Exception e) { - e.printStackTrace(); - drawnImage = null; - setPreferredSize(new Dimension(100, 100)); - revalidate(); - repaint(); - } - } - - } - - @Override - public void disconnect() { - bgThread.destroy(); - gcThread.destroy(); - if(cam != null) cam.dispose(); - super.disconnect(); - } - - @Override - protected void paintComponent(Graphics g) { - if (drawnImage != null) { - if (!resized) { - setPreferredSize(new Dimension(drawnImage.getWidth(), drawnImage.getHeight())); - revalidate(); - } - int width = getBounds().width; - int height = getBounds().height; - double scale = Math.min((double) width / (double) drawnImage.getWidth(), (double) height / (double) drawnImage.getHeight()); - g.drawImage(drawnImage, (int) (width - (scale * drawnImage.getWidth())) / 2, (int) (height - (scale * drawnImage.getHeight())) / 2, - (int) ((width + scale * drawnImage.getWidth()) / 2), (int) (height + scale * drawnImage.getHeight()) / 2, - 0, 0, drawnImage.getWidth(), drawnImage.getHeight(), null); - } else { - g.setColor(Color.PINK); - g.fillRect(0, 0, getBounds().width, getBounds().height); - g.setColor(Color.BLACK); - g.drawString("NO CONNECTION", 10, 10); - } - } - - public WPIImage processImage(WPIColorImage rawImage) { - return rawImage; - } - - public WPIImage processImage(WPIGrayscaleImage rawImage) { - return rawImage; - } -} diff --git a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPIFFmpegVideoViewer.java b/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPIFFmpegVideoViewer.java deleted file mode 100644 index b8a149d..0000000 --- a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPIFFmpegVideoViewer.java +++ /dev/null @@ -1,133 +0,0 @@ -package edu.wpi.first.smartdashboard.camera; - -import com.googlecode.javacv.FFmpegFrameGrabber; -import static com.googlecode.javacv.cpp.opencv_core.*; -import com.googlecode.javacv.cpp.opencv_core.IplImage; -import edu.wpi.first.wpijavacv.WPIDisposable; -import edu.wpi.first.wpijavacv.WPIImage; -import java.awt.image.BufferedImage; - -/** - * A class used to gather images from the robot's camera. - * @author Joe Grinstead and Greg Granito - */ -public class WPIFFmpegVideoViewer extends WPIDisposable { - - private FFmpegFrameGrabber grabber; - private IplImage image; - private boolean readImage = true; - private boolean badConnection = false; - private final Object imageLock = new Object(); - private final Object grabberLock = new Object(); - - public WPIFFmpegVideoViewer(final String path) { - new Thread() { - - @Override - public void run() { - grabber = new FFmpegFrameGrabber(path); - grabber.setFrameRate(1.0); - try { - grabber.start(); - - while (!isDisposed()) { - try { - IplImage newest; - synchronized (grabberLock) { - if (isDisposed()) { - return; - } - newest = grabber.grab(); - } - if (isNull(newest)) { - synchronized (imageLock) { - badConnection = true; - imageLock.notify(); - } - return; - } else { - synchronized (imageLock) { - if (image == null) { - image = cvCreateImage(newest.cvSize(), newest.depth(), newest.nChannels()); - } - cvCopy(newest, image); - readImage = false; - badConnection = false; - imageLock.notify(); - } - } - } catch (Exception ex) { - synchronized (imageLock) { - badConnection = true; - imageLock.notify(); - } - ex.printStackTrace(); - return; - } - try { - Thread.sleep(20); - } catch (InterruptedException ex) { - } - } - } catch (Exception ex) { - synchronized (imageLock) { - badConnection = true; - imageLock.notify(); - } - ex.printStackTrace(); - } - } - }.start(); - } - - public BufferedImage getNewImage(double timeout) throws BadConnectionException { - validateDisposed(); - - synchronized (imageLock) { - readImage = true; - while (readImage && !badConnection) { - try { - badConnection = true; - imageLock.wait((long) (timeout * 1000)); - } catch (InterruptedException ex) { - } - } - readImage = true; - - - if (badConnection) { - throw new BadConnectionException(); - } else if (image == null) { - return null; - } else { - return image.getBufferedImage(); - } - } - } - - @Override - protected void disposed() { - try { - synchronized (imageLock) { - if (!isNull(image)) { - image.release(); - } - image = null; - } - } catch (Exception ex) { - } - } - - /** - * An exception that occurs when the camera can not be reached. - * @author Greg Granito - */ - public static class BadConnectionException extends Exception { - } - - @Override - protected void finalize() throws Throwable { - grabber.stop(); - super.finalize(); - } -} diff --git a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPILaptopCameraExtension.java b/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPILaptopCameraExtension.java deleted file mode 100644 index 32e17cc..0000000 --- a/extensions/camera/WPICameraExtension/src/edu/wpi/first/smartdashboard/camera/WPILaptopCameraExtension.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.smartdashboard.camera; - -import edu.wpi.first.smartdashboard.gui.DashboardFrame; -import edu.wpi.first.smartdashboard.gui.StaticWidget; -import edu.wpi.first.smartdashboard.properties.Property; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import javax.swing.SwingUtilities; -import edu.wpi.first.wpijavacv.WPIColorImage; -import edu.wpi.first.wpijavacv.WPIGrayscaleImage; -import edu.wpi.first.wpijavacv.WPIImage; -import edu.wpi.first.wpijavacv.WPILaptopCamera; - -/** - * An extension that gets images from a webcam on the computer. - * @author Greg Granito - */ -public class WPILaptopCameraExtension extends StaticWidget { - - public static final String NAME = "Laptop Camera"; - private boolean connected = false; - - public class GCThread extends Thread { - - boolean destroyed = false; - - @Override - public void run() { - while (!destroyed) { - try { - Thread.sleep(10000); - } catch (InterruptedException ex) { - } - System.gc(); - } - } - - public void destroy() { - destroyed = true; - interrupt(); - } - } - - public class BGThread extends Thread { - - boolean destroyed = false; - - public BGThread() { - super("Camera Background"); - } - - @Override - public void run() { - WPIImage image; - while (!destroyed) { - if (cam == null) { - cam = new WPILaptopCamera(); - } - try { - image = cam.getCurrentFrame(); - - if (image instanceof WPIColorImage) { - drawnImage = processImage((WPIColorImage) image).getBufferedImage(); - repaint(); - } else if (image instanceof WPIGrayscaleImage) { - drawnImage = processImage((WPIGrayscaleImage) image).getBufferedImage(); - repaint(); - } - } catch (final Exception e) { - drawnImage = null; - repaint(); - try { - Thread.sleep(500); - } catch (InterruptedException ex) { - } - } - } - - } - - @Override - public void destroy() { - destroyed = true; - } - } - private boolean resized = false; - private WPILaptopCamera cam; - private BufferedImage drawnImage; - private BGThread bgThread = new BGThread(); - private GCThread gcThread = new GCThread(); - - @Override - public void init() { - setPreferredSize(new Dimension(100, 100)); - bgThread.start(); - gcThread.start(); - revalidate(); - repaint(); - } - - @Override - public void propertyChanged(Property property) { - - } - - @Override - public void disconnect() { - bgThread.destroy(); - gcThread.destroy(); - cam.dispose(); - super.disconnect(); - } - - @Override - protected void paintComponent(Graphics g) { - if (drawnImage != null) { - if (!resized) { - setPreferredSize(new Dimension(drawnImage.getWidth(), drawnImage.getHeight())); - revalidate(); - } - int width = getBounds().width; - int height = getBounds().height; - double scale = Math.min((double) width / (double) drawnImage.getWidth(), (double) height / (double) drawnImage.getHeight()); - g.drawImage(drawnImage, (int) (width - (scale * drawnImage.getWidth())) / 2, (int) (height - (scale * drawnImage.getHeight())) / 2, - (int) ((width + scale * drawnImage.getWidth()) / 2), (int) (height + scale * drawnImage.getHeight()) / 2, - 0, 0, drawnImage.getWidth(), drawnImage.getHeight(), null); - } else { - g.setColor(Color.PINK); - g.fillRect(0, 0, getBounds().width, getBounds().height); - g.setColor(Color.BLACK); - g.drawString("NO CONNECTION", 10, 10); - } - } - - public WPIImage processImage(WPIColorImage rawImage) { - return rawImage; - } - - public WPIImage processImage(WPIGrayscaleImage rawImage) { - return rawImage; - } -} -- cgit v1.2.3-54-g00ecf