コード例 #1
0
 /**
  * Initializes the tile grid
  *
  * @param params the stitching parameters
  * @param classType the class type
  */
 public TileGrid(StitchingAppParams params, Class<?> classType) throws InvalidClassException {
   this(
       params.getInputParams().getStartRow(),
       params.getInputParams().getStartCol(),
       params.getInputParams().getExtentWidth(),
       params.getInputParams().getExtentHeight(),
       params.getInputParams().getTileGridLoader(),
       new File(params.getInputParams().getImageDir()),
       classType);
 }
コード例 #2
0
  private static void runFolder(boolean useMLE) {
    // get all folders in root folder
    File rootFolder = new File(validationRootFolder);
    if (!rootFolder.exists() && !rootFolder.isDirectory()) {
      System.out.println("Error: Unable to find root folder: " + validationRootFolder);
      System.exit(1);
    }

    File[] roots = rootFolder.listFiles();

    CUDAPanel cudaPanel = new CUDAPanel();

    //    JFrame frame = new JFrame("Select CUDA Devices");
    //    JOptionPane.showMessageDialog(frame, cudaPanel);

    Log.setLogLevel(LogType.NONE);
    //    Log.setLogLevel(LogType.MANDATORY);

    StitchingAppParams params;

    File runtimeResults;
    if (useMLE) {
      runtimeResults = new File(validationRootFolder + File.separator + "mle-runtimes.txt");
    } else {
      runtimeResults = new File(validationRootFolder + File.separator + "runtimes.txt");
    }
    try {
      FileWriter writer = new FileWriter(runtimeResults);
      writer.write("testCase, totalTime" + "\n");

      for (File r : roots) {

        if (!r.isDirectory()) continue;

        params = new StitchingAppParams();

        File paramFile = new File(r, STITCHING_PARAMS_FILE);

        if (!paramFile.exists()) continue;

        System.out.println("Running: " + r.getAbsolutePath());

        params.loadParams(paramFile);

        List<CudaDeviceParam> cudaDevices = cudaPanel.getSelectedDevices();

        params.getInputParams().setImageDir(r.getAbsolutePath());
        params.getAdvancedParams().setNumCPUThreads(Runtime.getRuntime().availableProcessors());
        params.getAdvancedParams().setPlanPath(fftwPlanPath);
        params.getAdvancedParams().setFftwLibraryPath(fftwLibraryPath);
        params.getAdvancedParams().setFftwPlanType(FftwPlanType.MEASURE);
        params.getAdvancedParams().setCudaDevices(cudaPanel.getSelectedDevices());
        params.getOutputParams().setOutputMeta(false);
        params
            .getOutputParams()
            .setOutputPath(r.getAbsolutePath() + File.separator + "RunTimeResults");
        // set the metadata path to the output path

        params.getOutputParams().setOutputFullImage(true);
        params.getOutputParams().setDisplayStitching(false);
        //      params.getAdvancedParams().setNumCPUThreads(8);

        if (useMLE) {
          params.getAdvancedParams().setOverlapComputationType(OptimizationUtils.OverlapType.MLE);
          params
              .getAdvancedParams()
              .setTranslationFilterType(OptimizationUtils.TranslationFilterType.Outlier);
        } else {
          params
              .getAdvancedParams()
              .setOverlapComputationType(OptimizationUtils.OverlapType.Heuristic);
          params
              .getAdvancedParams()
              .setTranslationFilterType(OptimizationUtils.TranslationFilterType.StandardDeviation);
        }

        for (StitchingType t : StitchingType.values()) {
          String testCase = t.toString() + "-" + r.getName();

          if (t == StitchingType.AUTO || t == StitchingType.JAVA || t == StitchingType.FFTW)
            continue;

          if (t == StitchingType.CUDA) {
            if (!cudaPanel.isCudaAvailable()) continue;
          }

          double totalRunTime = 0;
          for (int run = 0; run < NUM_RUNS; run++) {

            System.out.println("Run " + run + " Stitching Type: " + t + " " + testCase);

            //        File metaDataPath = new File(r, t.name().toLowerCase());
            //        File metaDataPath = new File(r, "seq");
            //        params.getOutputParams().setMetadataPath(metaDataPath.getAbsolutePath());
            params.getAdvancedParams().setProgramType(t);
            params.getAdvancedParams().setNumFFTPeaks(2);

            StitchingExecutor executor = new StitchingExecutor(params);

            try {
              executor.runStitching(false, false, false);
            } catch (StitchingException e) {
              Log.msg(LogType.MANDATORY, e.getMessage());
            }

            StitchingStatistics stats = executor.getStitchingStatistics();
            totalRunTime += stats.getDuration(StitchingStatistics.RunTimers.TotalStitchingTime);
          }

          double avgRunTime = totalRunTime / ((double) NUM_RUNS);
          writer.write(testCase + ", " + avgRunTime + "\n");
          writer.flush();
        }
      }

      writer.close();

    } catch (IOException e) {
      e.printStackTrace();
    }
  }