public double getDistance(Target t) {
    boolean debugMyProc = true;
    double result;

    if (debugMyProc) {
      writeDebug("t.rawBboxHeight=" + t.rawBboxHeight);
      writeDebug("Center x, y (" + t.centerX + "," + t.centerY + ")");
      writeDebug("Cornerr x, y (" + t.rawBboxCornerX + "," + t.rawBboxCornerY + ")");
    }
    result = 3185.6 / (t.rawBboxHeight * Math.tan(0.4101));
    return (result * 1.0125);
  }
Пример #2
0
  /**
   * Computes the distance away from the target
   *
   * @param image The image containing the particle to score
   * @param report The Particle Analysis Report for the particle
   * @param particleNumber Particle number in the analysis
   * @param outer Indicates whether the particle aspect ratio should be compared to the ratio for
   *     the inner target or the outer
   * @return Approximate distance from the target
   * @throws NIVisionException
   */
  double computeDistance(
      BinaryImage image, ParticleAnalysisReport report, int particleNumber, boolean outer)
      throws NIVisionException {
    double rectShort, height;
    int targetHeight;
    angle = CommandBase.shooterPitch.getPosition();

    rectShort =
        NIVision.MeasureParticle(
            image.image, particleNumber, false, MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
    // using the smaller of the estimated rectangle short side and the bounding rectangle height
    // results in better performance
    // on skewed rectangles
    height = Math.min(report.boundingRectHeight, rectShort);
    targetHeight = outer ? 29 : 21;

    return X_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(angle * Math.PI / (180 * 2)));
  }