delete lines of code that will disregard detected goal if width is less than height cindy/openCV-Vision/Parked
authorKevin Zhang <kevin.zhang.13499@gmail.com>
Sat, 30 Jan 2016 23:43:11 +0000 (15:43 -0800)
committerKevin Zhang <kevin.zhang.13499@gmail.com>
Sat, 30 Jan 2016 23:43:11 +0000 (15:43 -0800)
src/org/usfirst/frc/team3501/robot/subsystems/TowerTracker.java

index b4e040841da628e87a52511f64f0a938ad1ec4a1..3b89cbcca991c940a4049309c1704089aa28e8c3 100644 (file)
@@ -13,8 +13,6 @@ import org.opencv.core.Size;
 import org.opencv.imgproc.Imgproc;
 import org.opencv.videoio.VideoCapture;
 
-import edu.wpi.first.wpilibj.networktables.NetworkTable;
-
 /**
  *
  */
@@ -33,28 +31,25 @@ public class TowerTracker {
    */
   static {
     System
-    .setProperty(
-            "java.library.path",
-            System.getProperty("java.library.path")
-                + ":/home/cindy/Robotics/Workspace/opencv-3.1.0/cmake/lib" //path to opencv_java310
-                + ":/home/cindy/wpilib/cpp/current/lib");
-    System.out.println(System.getProperty("java.library.path"));
+        .setProperty(
+        "java.library.path",
+        System.getProperty("java.library.path")
+        + ":/home/cindy/Robotics/Workspace/opencv-3.1.0/cmake/lib"); // path
+    // to
+    // opencv_java310
+    // System.out.println(System.getProperty("java.library.path"));
     System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
-    NetworkTable.setClientMode();
-    NetworkTable.setIPAddress("roborio-3502.local");
   }
   // constants for the color rbg values
   public static final Scalar
-      RED = new Scalar(0, 0, 255),
-      BLUE = new Scalar(255, 0, 0),
-      GREEN = new Scalar(0, 255, 0),
-      BLACK = new Scalar(0, 0, 0),
-      YELLOW = new Scalar(0, 255, 255),
-      // these are the threshold values in order
-      // LOWER_BOUNDS = new Scalar(58, 0, 109),
-      // UPPER_BOUNDS = new Scalar(93, 255, 240);
-      LOWER_BOUNDS = new Scalar(6, 15, 13),
-      UPPER_BOUNDS = new Scalar(31, 115, 45);
+  RED = new Scalar(0, 0, 255),
+  BLUE = new Scalar(255, 0, 0),
+  GREEN = new Scalar(0, 255, 0),
+  BLACK = new Scalar(0, 0, 0),
+  YELLOW = new Scalar(0, 255, 255),
+  // these are the threshold values in order
+  LOWER_BOUNDS = new Scalar(58, 0, 109),
+  UPPER_BOUNDS = new Scalar(93, 255, 240);
 
   // the size for resing the image
   public static final Size resize = new Size(320, 240);
@@ -82,36 +77,15 @@ public class TowerTracker {
    *          command line arguments
    *          just the main loop for the program and the entry points
    */
-  public static void main(String[] args) {
+  public TowerTracker() {
     // TODO Auto-generated method stub
     matOriginal = new Mat();
     matHSV = new Mat();
     matThresh = new Mat();
     clusters = new Mat();
     matHeirarchy = new Mat();
-    NetworkTable table = NetworkTable.getTable("SmartDashboard");
-    // main loop of the program
-    while (shouldRun) {
-      try {
-        // opens up the camera stream and tries to load it
-        videoCapture = new VideoCapture();
-        // replaces the ##.## with your team number
-        videoCapture.open("http://10.##.##.11/mjpg/video.mjpg");
-        // Example
-        // cap.open("http://10.30.19.11/mjpg/video.mjpg");
-        // wait until it is opened
-        while (!videoCapture.isOpened()) {
-        }
-        // time to actually process the acquired images
-        processImage();
-      } catch (Exception e) {
-        e.printStackTrace();
-        break;
-      }
-    }
-    // make sure the java process quits when the loop finishes
+    processImage();
     videoCapture.release();
-    System.exit(0);
   }
 
   /**