start debugging Vision code
authorKevin Zhang <kevin.zhang.13499@gmail.com>
Sun, 24 Jan 2016 01:39:56 +0000 (17:39 -0800)
committerKevin Zhang <kevin.zhang.13499@gmail.com>
Sun, 24 Jan 2016 01:39:56 +0000 (17:39 -0800)
http://www.chiefdelphi.com/forums/showthread.php?s=a86abd39c41285aa57ca26784ae3d1fa&threadid=142173

add file path of library to java library path to fix build error

src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/subsystems/TowerTracker.java

index 36ca70bc268a526c02d33f5531c1d8d550fcbe90..d8c89e1f655f45fad5d411ffbcf24c5a3255503b 100644 (file)
@@ -1,17 +1,21 @@
 package org.usfirst.frc.team3501.robot;
 
 import org.usfirst.frc.team3501.robot.Constants.DriveTrain;
+import org.usfirst.frc.team3501.robot.subsystems.TowerTracker2;
+
 import edu.wpi.first.wpilibj.IterativeRobot;
 import edu.wpi.first.wpilibj.command.Scheduler;
 
 public class Robot extends IterativeRobot {
   public static OI oi;
   public static DriveTrain driveTrain;
+  public static TowerTracker2 towerTracker;
 
   @Override
   public void robotInit() {
     driveTrain = new DriveTrain();
     oi = new OI();
+    towerTracker = new TowerTracker2();
   }
 
   @Override
@@ -31,6 +35,5 @@ public class Robot extends IterativeRobot {
   @Override
   public void teleopPeriodic() {
     Scheduler.getInstance().run();
-
   }
 }
index 8e5f65cbb1fb7e81273e0724ee089f0b0ce96384..b4e040841da628e87a52511f64f0a938ad1ec4a1 100644 (file)
@@ -10,7 +10,6 @@ import org.opencv.core.Point;
 import org.opencv.core.Rect;
 import org.opencv.core.Scalar;
 import org.opencv.core.Size;
-import org.opencv.imgcodecs.Imgcodecs;
 import org.opencv.imgproc.Imgproc;
 import org.opencv.videoio.VideoCapture;
 
@@ -33,9 +32,16 @@ public class TowerTracker {
    * static method to load opencv and networkTables
    */
   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"));
     System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
     NetworkTable.setClientMode();
-    NetworkTable.setIPAddress("roborio-3019.local");
+    NetworkTable.setIPAddress("roborio-3502.local");
   }
   // constants for the color rbg values
   public static final Scalar
@@ -45,8 +51,10 @@ public class TowerTracker {
       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(58, 0, 109),
+      // UPPER_BOUNDS = new Scalar(93, 255, 240);
+      LOWER_BOUNDS = new Scalar(6, 15, 13),
+      UPPER_BOUNDS = new Scalar(31, 115, 45);
 
   // the size for resing the image
   public static final Size resize = new Size(320, 240);
@@ -164,13 +172,15 @@ public class TowerTracker {
             - rec.height / 2);
         Point centerw = new Point(rec.br().x - rec.width / 2 - 15, rec.br().y
             - rec.height / 2 - 20);
-        Imgproc.putText(matOriginal, "" + (int) distance, center,
-            Core.FONT_HERSHEY_PLAIN, 1, BLACK);
-        Imgproc.putText(matOriginal, "" + (int) azimuth, centerw,
-            Core.FONT_HERSHEY_PLAIN, 1, BLACK);
+        // Imgproc.putText(matOriginal, "" + (int) distance, center,
+        // Core.FONT_HERSHEY_PLAIN, 1, BLACK);
+        // Imgproc.putText(matOriginal, "" + (int) azimuth, centerw,
+        // Core.FONT_HERSHEY_PLAIN, 1, BLACK);
+        System.out.println(distance + "m, " + azimuth + " degrees     "
+            + center.x + ", " + center.y);
       }
       // output an image for debugging
-      Imgcodecs.imwrite("output.png", matOriginal);
+      // Imgcodecs.imwrite("output.png", matOriginal);
       FrameCount++;
     }
     shouldRun = false;