Example #1
0
  /**
   * @return a new default settings map suitable for the target tracker identified by the {@link
   *     #currentKey}. Settings are instantiated with default values. If the key is unknown to this
   *     provider, <code>null</code> is returned.
   */
  public Map<String, Object> getDefaultSettings() {
    Map<String, Object> settings;

    if (currentKey.equals(SimpleFastLAPTracker.TRACKER_KEY)
        || currentKey.equals(FastLAPTracker.TRACKER_KEY)) {
      settings = LAPUtils.getDefaultLAPSettingsMap();

    } else if (currentKey.equals(NearestNeighborTracker.TRACKER_KEY)) {
      settings = new HashMap<String, Object>();
      settings.put(KEY_LINKING_MAX_DISTANCE, DEFAULT_LINKING_MAX_DISTANCE);

    } else {
      return null;
    }
    return settings;
  }
Example #2
0
  /**
   * Check the validity of the given settings map for the target {@link SpotDetector} set in this
   * provider. The validity check is strict: we check that all needed parameters are here and are of
   * the right class, and that there is no extra unwanted parameters.
   *
   * @return true if the settings map can be used with the target factory. If not, check {@link
   *     #getErrorMessage()}
   */
  public boolean checkSettingsValidity(final Map<String, Object> settings) {
    if (null == settings) {
      errorMessage = "Settings map is null.\n";
      return false;
    }

    final StringBuilder str = new StringBuilder();
    boolean ok = true;

    if (currentKey.equals(FastLAPTracker.TRACKER_KEY)
        || currentKey.equals(SimpleFastLAPTracker.TRACKER_KEY)) {

      ok = LAPUtils.checkSettingsValidity(settings, str);
      if (!ok) {
        errorMessage = str.toString();
      }
      return ok;

    } else if (currentKey.equals(NearestNeighborTracker.TRACKER_KEY)) {

      ok = NearestNeighborTracker.checkInput(settings, str);
      if (!ok) {
        errorMessage = str.toString();
      }
      return ok;

    } else if (currentKey.equals(ManualTracker.TRACKER_KEY)) {

      return true;

    } else {

      errorMessage = "Unknow detector factory key: " + currentKey + ".\n";
      return false;
    }
  }
Example #3
0
  /**
   * A utility method that builds a string representation of a settings map owing to the currently
   * selected tracker in this provider.
   */
  @SuppressWarnings("unchecked")
  public String toString(final Map<String, Object> sm) {

    if (!checkSettingsValidity(sm)) {
      return errorMessage;
    }

    final StringBuilder str = new StringBuilder();
    if (currentKey.equals(FastLAPTracker.TRACKER_KEY)
        || currentKey.equals(SimpleFastLAPTracker.TRACKER_KEY)) {

      str.append("  Linking conditions:\n");
      str.append(
          String.format("    - max distance: %.1f\n", (Double) sm.get(KEY_LINKING_MAX_DISTANCE)));
      str.append(
          LAPUtils.echoFeaturePenalties(
              (Map<String, Double>) sm.get(KEY_LINKING_FEATURE_PENALTIES)));

      if ((Boolean) sm.get(KEY_ALLOW_GAP_CLOSING)) {
        str.append("  Gap-closing conditions:\n");
        str.append(
            String.format(
                "    - max distance: %.1f\n", (Double) sm.get(KEY_GAP_CLOSING_MAX_DISTANCE)));
        str.append(
            String.format(
                "    - max frame gap: %d\n", (Integer) sm.get(KEY_GAP_CLOSING_MAX_FRAME_GAP)));
        str.append(
            LAPUtils.echoFeaturePenalties(
                (Map<String, Double>) sm.get(KEY_GAP_CLOSING_FEATURE_PENALTIES)));
      } else {
        str.append("  Gap-closing not allowed.\n");
      }

      if ((Boolean) sm.get(KEY_ALLOW_TRACK_SPLITTING)) {
        str.append("  Track splitting conditions:\n");
        str.append(
            String.format(
                "    - max distance: %.1f\n", (Double) sm.get(KEY_SPLITTING_MAX_DISTANCE)));
        str.append(
            LAPUtils.echoFeaturePenalties(
                (Map<String, Double>) sm.get(KEY_SPLITTING_FEATURE_PENALTIES)));
      } else {
        str.append("  Track splitting not allowed.\n");
      }

      if ((Boolean) sm.get(KEY_ALLOW_TRACK_MERGING)) {
        str.append("  Track merging conditions:\n");
        str.append(
            String.format("    - max distance: %.1f\n", (Double) sm.get(KEY_MERGING_MAX_DISTANCE)));
        str.append(
            LAPUtils.echoFeaturePenalties(
                (Map<String, Double>) sm.get(KEY_MERGING_FEATURE_PENALTIES)));
      } else {
        str.append("  Track merging not allowed.\n");
      }

    } else if (currentKey.equals(NearestNeighborTracker.TRACKER_KEY)) {
      str.append(
          String.format("  Max distance: %.1f\n", (Double) sm.get(KEY_LINKING_MAX_DISTANCE)));

    } else if (currentKey.equals(ManualTracker.TRACKER_KEY)) {
      str.append("  Manual tracking.\n");
    }
    return str.toString();
  }