private void evaluateScenario(File inputDirectory) {

    List<T> frames = new ArrayList<T>();

    IntrinsicParameters intrinsic =
        FiducialCommon.parseIntrinsic(new File(inputDirectory, "intrinsic.txt"));

    FiducialDetector<T> detector = factory.createDetector(inputDirectory);
    detector.setIntrinsic(intrinsic);

    File[] files = inputDirectory.listFiles();
    for (File f : files) {
      BufferedImage image = UtilImageIO.loadImage(f.getPath());
      if (image == null) continue;

      T frame = ConvertBufferedImage.convertFrom(image, true, detector.getInputType());
      frames.add(frame);
    }

    long startTime = System.currentTimeMillis();
    for (int trial = 0; trial < numFrames; trial++) {
      detector.detect(frames.get(trial % frames.size()));
    }
    long endTime = System.currentTimeMillis();

    double fps = numFrames / ((endTime - startTime) / 1000.0);

    outputResults.printf("%s %d %7.3f\n", inputDirectory.getPath(), numFrames, fps);
  }
  public RigidBodyTransform detect(BufferedImage image) {
    if (intrinsicParameters == null)
      setDefaultIntrinsicParameter(image.getHeight(), image.getWidth(), Math.PI / 4);
    ImageFloat32 gray = new ImageFloat32(image.getWidth(), image.getHeight());
    ConvertBufferedImage.convertFrom(image, gray);
    detector.setIntrinsic(intrinsicParameters);
    detector.detect(gray);

    // display the results
    if (detector.totalFound() == 0) {
      return null;
    } else {
      int closestIndex = -1;
      double closestDistance = Double.MAX_VALUE;
      Se3_F64 targetToSensor = new Se3_F64();
      for (int i = 0; i < detector.totalFound(); i++) {
        detector.getFiducialToCamera(i, targetToSensor);
        double dist = targetToSensor.getT().norm();
        if (dist < closestDistance) {
          closestIndex = i;
          closestDistance = dist;
        }
      }
      detector.getFiducialToCamera(closestIndex, targetToSensor);
      Vector3D_F64 translation = targetToSensor.getT();
      Matrix3d rotation = new Matrix3d(targetToSensor.getR().data);

      RigidBodyTransform transform =
          new RigidBodyTransform(
              rotation, new Vector3d(translation.x, translation.y, translation.z));
      return transform;
    }
  }