Пример #1
0
  /**
   * This method takes in the batch InstanceID and subsequently gets the parsedXMLFile. Then it
   * fetches all the Pages from it as they are with a document type unknown. and it classifies all
   * the pages based on Image comparison. In the end the result is put in the batch.xml file.
   *
   * @param batchInstanceIdentifier {@link String}
   * @param sBatchFolder {@link String}
   * @throws IOException for any input output exception
   * @throws DCMAApplicationException for any other type of exception that occurs.
   */
  public void classifyAllImgsOfBatch(String batchInstanceIdentifier, String sBatchFolder)
      throws IOException, DCMAApplicationException {

    // Initialize properties
    LOGGER.info("Initializing properties...");
    Batch parsedXmlFile = batchSchemaService.getBatch(batchInstanceIdentifier);
    String batchClassIdentifier = parsedXmlFile.getBatchClassIdentifier();
    LOGGER.info("batchClassIdentifier = " + batchClassIdentifier);
    String sampleBaseFolderPath =
        batchSchemaService.getImageMagickBaseFolderPath(batchClassIdentifier, false);

    String imMetric =
        pluginPropertiesService.getPropertyValue(
            batchInstanceIdentifier,
            ImageMagicKConstants.CLASSIFY_IMAGES_PLUGIN,
            ImageMagicProperties.CLASSIFY_IMAGES_COMP_METRIC);
    String imFuzz =
        pluginPropertiesService.getPropertyValue(
            batchInstanceIdentifier,
            ImageMagicKConstants.CLASSIFY_IMAGES_PLUGIN,
            ImageMagicProperties.CLASSIFY_IMAGES_FUZZ_PERCNT);
    String maxVal =
        pluginPropertiesService.getPropertyValue(
            batchInstanceIdentifier,
            ImageMagicKConstants.CLASSIFY_IMAGES_PLUGIN,
            ImageMagicProperties.CLASSIFY_IMAGES_MAX_RESULTS);

    LOGGER.info(
        "Properties Initialized Successfully, sampleBaseFolderPath = " + sampleBaseFolderPath);

    // Get list of Page names from parsedXmlFile.
    List<String> listOfUnclasifiedPgPth = new LinkedList<String>();
    Map<String, Integer> unclassifiedPgIndexMap = new HashMap<String, Integer>();

    getPathOfPagesOfBatch(
        parsedXmlFile, listOfUnclasifiedPgPth, unclassifiedPgIndexMap, sBatchFolder);
    Map<String, CustomValueSortedMap> finalUnclasifiedPageConfidenceMap =
        performClassification(
            maxVal, imMetric, imFuzz, sampleBaseFolderPath, listOfUnclasifiedPgPth);

    List<Document> listOfDocuments = parsedXmlFile.getDocuments().getDocument();
    Document docuemnt = listOfDocuments.get(0);
    Pages pages = docuemnt.getPages();
    List<Page> listOfPages = pages.getPage();

    updateXmlObject(finalUnclasifiedPageConfidenceMap, unclassifiedPgIndexMap, listOfPages);
    batchSchemaService.updateBatch(parsedXmlFile);
  }
Пример #2
0
 private void getPathOfPagesOfBatch(
     Batch parsedXmlFile,
     List<String> listOfUnclasifiedPages,
     Map<String, Integer> unclassifiedPgIndexMap,
     String sBatchFolder) {
   Documents documents = parsedXmlFile.getDocuments();
   boolean valid = true;
   if (documents == null) {
     valid = false;
   }
   List<Document> listOfDocuments = null;
   List<Page> listOfPages = null;
   if (valid) {
     listOfDocuments = documents.getDocument();
     if (listOfDocuments == null || listOfDocuments.isEmpty()) {
       valid = false;
     } else {
       Document unknownDocument = listOfDocuments.get(0);
       Pages pages = unknownDocument.getPages();
       listOfPages = pages.getPage();
       if (listOfPages == null || listOfPages.isEmpty()) {
         valid = false;
       }
     }
   }
   if (valid) {
     processPageList(listOfPages, listOfUnclasifiedPages, unclassifiedPgIndexMap, sBatchFolder);
   }
 }