Package eu.planets_project.services.compare

Examples of eu.planets_project.services.compare.CompareResult


         
          DigitalObject digo1 = this.getDataRegistry().retrieve(digo1Ref);
          DigitalObject digo2 = this.getDataRegistry().retrieve(digo2Ref);
     
          //call the comparison service
      CompareResult result = comparexcdl1.compare(digo1, digo2,
          configProperties);
       
      //document
      wfResultItem.setEndTime(System.currentTimeMillis());
      ServiceReport report = result.getReport();
      //report service status and type
      wfResultItem.setServiceReport(report);
      if (report.getType() == Type.ERROR) {
        String s = "Service execution failed: " + report.getMessage();
        wfResultItem.addLogInfo(s);
        throw new Exception(s);
      }
      //document: add report on outputDigitalObject
      wfResultItem.addExtractedInformation(result.getProperties().toString());
      wfResultItem.addLogInfo("comparisson completed");
     
    } catch (Exception e) {
      wfResultItem.addLogInfo("comparisson failed: "+e);
      throw e;
View Full Code Here


       
        DigitalObjectContent c2 = Content.byReference(purl2.toURL());
        DigitalObject o2 = new DigitalObject.Builder(c2).permanentUri(purl2.toURI()).build();
       
        /* Now pass this to the service */
        CompareResult ir = ids.compare( o1, o2, null);
       
        /* Check the result */
        Boolean foundIdentical = null;
        for( PropertyComparison pc : ir.getComparisons() ) {
            Property p = pc.getComparison();
//            System.out.println("Recieved property: " + p );
            if( p != null && JavaImageIOCompare.PSNR_URI.equals(p.getUri())) {
                System.out.println(p.getName()+" = "+p.getValue()+" ["+p.getUnit()+"]");
                double psnr = Double.parseDouble(p.getValue());
                if( Double.isInfinite(psnr) ) {
                    foundIdentical = true;
                } else {
                    foundIdentical = false;
                }
            }
        }
        assertTrue("The service should have been able to determine the PSNR for these images!", foundIdentical != null );
        assertTrue("The images were not correctly determined to be identical or not.", foundIdentical.booleanValue() == same);
        System.out.println("Recieved service report: " + ir.getReport() );
        System.out.println("Recieved service properties: " );
        ServiceProperties.printProperties(System.out, ir.getReport().getProperties());
       
    }
View Full Code Here

         
          DigitalObject digo1 = this.getDataRegistry().retrieve(digo1Ref);
          DigitalObject digo2 = this.getDataRegistry().retrieve(digo2Ref);
     
          //call the comparison service
      CompareResult result = comparexcdl1.compare(digo1, digo2,
          configProperties);
       
      //document
      wfResultItem.setEndTime(System.currentTimeMillis());
      ServiceReport report = result.getReport();
      //report service status and type
      wfResultItem.setServiceReport(report);
      if (report.getType() == Type.ERROR) {
        String s = "Service execution failed: " + report.getMessage();
        wfResultItem.addLogInfo(s);
        throw new Exception(s);
      }
      //document: add report on outputDigitalObject
      wfResultItem.addExtractedInformation(result.getProperties().toString());
      wfResultItem.addLogInfo("comparisson completed");
     
    } catch (Exception e) {
      wfResultItem.addLogInfo("comparisson failed: "+e);
      throw e;
View Full Code Here

      //retrieve the digital objects from their data registry location
      DigitalObject digo1 = this.retrieveDigitalObjectDataRegistryRef(digo1Ref);
      DigitalObject digo2 = this.retrieveDigitalObjectDataRegistryRef(digo2Ref);
     
      // now call the comparison
      CompareResult compareResult = compareService.compare(digo1,digo2, parameterList);
     
      // document
      wfResultItem.setEndTime(System.currentTimeMillis());
      ServiceReport report = compareResult.getReport();
      // report service status and type
      wfResultItem.setServiceReport(report);
      if (report.getType() == Type.ERROR) {
        String s = "Service execution failed: " + report.getMessage();
        wfResultItem.addLogInfo(s);
        throw new Exception(s);
      }
     
      //document the comparison's output
      if((compareResult.getProperties()!=null)&&(compareResult.getProperties().size()>0)){
        wfResultItem.addLogInfo("Comparing properties of object A: "+digo1.getPermanentUri()+" with object B: "+digo2.getPermanentUri());
        for(Property p : compareResult.getProperties()){
          String extractedInfo = "[name: "+p.getName()+" value: "+p.getValue()+" untit: "+p.getUnit()+" description:"+p.getDescription()+"] \n";
          wfResultItem.addExtractedInformation(extractedInfo);
        }
      }
      else{
View Full Code Here

            ServiceDescription sd = compareServices.get(surl);
           
            if( sd.getType().equals(Compare.class.getCanonicalName()) ) {

                Compare chr = new CompareWrapper(surl);
                CompareResult cr = chr.compare( this.getDob1().getDob(), this.getDob2().getDob(), null);
                this.compareServiceReport = cr.getReport();

                me = this.createMeasurementEvent();
                if( me != null ) {
                    this.fillComparisonEvent(me, chr, cr);
                    ExperimentInspector.persistExperiment();
View Full Code Here

        BufferedImage i2;
        try {
            i1 = ImageIO.read( first.getContent().getInputStream() );
            i2 = ImageIO.read( second.getContent().getInputStream() );
        } catch (IOException e) {
            return new CompareResult(null, ServiceUtils.createExceptionErrorReport("IOException reading the images. ", e));
        }
        if( i1 == null || i2 == null ) {
            log.warning("One of the images was null when loaded!");
            return new CompareResult(null, ServiceUtils.createErrorReport("Error reading the images, got a NULL."));
        }
        // Record time take to load the inputs into memory:
        sph.loaded();
       
        // Check comparison is possible: Are the dimensions the same?
        if (i1.getWidth() != i2.getWidth() || i1.getHeight() != i2.getHeight()) {
            // FIXME is this really an error, or rather a 'images are different' result?
            return new CompareResult(null, ServiceUtils.createErrorReport("The image dimensions must match!"));
        }
        // FIXME Check comparison is sensible: are there the same number of channels? This is probably a WARNING?
        if( i1.getColorModel().getNumComponents() != i2.getColorModel().getNumComponents()) {
            System.out.println("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents());
            log.warning("The number of colour components does not match. "+i1.getColorModel().getNumComponents()+" != "+i2.getColorModel().getNumComponents());
            sr = new ServiceReport(ServiceReport.Type.WARN, ServiceReport.Status.SUCCESS, "Number of colour components was not the same. The missing channels, e.g. the alpha channel, will be assumed to be zero.");
            // FIXME I think this should be more serious, as the results can be rather misleading.
            // The comparison assumes the bit-mask to be zero everywhere, but this did not lead to such a bad PSNR?!
        }

        // Run the comparison:
        double psnr = psnr(i1, i2);
        props.add( buildPsnrProperty(psnr) );
       
        // Create a happy service report if no problems occurred.
        if( sr == null) {
            // Also store some service properties:
            sr = new ServiceReport(ServiceReport.Type.INFO, ServiceReport.Status.SUCCESS,
                    "Comparison succeeded.", sph.getPerformanceProperties() );
        }
       
        // Halt performance measurement:
        sph.stop();

        // Return the result:
        return new CompareResult( props, sr );
    }
View Full Code Here

TOP

Related Classes of eu.planets_project.services.compare.CompareResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.