示例#1
0
  public static void testTargetFeaturesAgainstImages(
      Vector<HaarFeature> features, Vector<IntegralImage> images) {
    int numberOfTrue = 0;
    int numberOfFalse = 0;

    for (IntegralImage ii : images) {
      float weightSum = 0.0f;
      float sum = 0.0f;
      for (HaarFeature hf : features) {
        //    			HaarFeature hf = allFeatures.get(slimFeature.featureNumber);
        //    			hf.threshold = slimFeature.threshold;
        float v = hf.weight * ii.evaluateAsClassifier(hf);
        sum += v;
        weightSum += hf.weight;
      }

      boolean success = (sum >= weightSum * 0.5f);
      //    		System.out.println("image " + ii.name + " is a " +  success + " : " + sum + " > " +
      // weightSum*0.5f);
      if (success) {
        numberOfTrue++;
      } else {
        numberOfFalse++;
      }
    }
    System.out.println("*************");
    System.out.println("true: " + numberOfTrue);
    System.out.println("false: " + numberOfFalse);

    int min = Math.min(numberOfFalse, numberOfTrue);
    int max = Math.max(numberOfFalse, numberOfTrue);

    float percentError = min * 100.0f / max;
    System.out.println("percentError = " + percentError);
  }