Menu

op.metric() does not work

niki
2012-12-12
2014-04-01
  • niki

    niki - 2012-12-12

    I am trying to compare 2 images and get the PSNR metric. When I use op.metric(\"PSNR\") it  does not return anything.
    I am using ArrayListOutputConsumer to capture the output.
    It works fine for op.verbose(),

     
  • Bernhard Bablok

    Bernhard Bablok - 2012-12-13

    Did you connect your ArrayListOutputConsumer with setErrorConsumer()? ImageMagick writes the metric-output to stderr, not to stdout. For an example, TestCase24.java in src/org/im4java/test.

    Bernhard

     
  • Bernhard Bablok

    Bernhard Bablok - 2012-12-13

    In fact, ArrayListOutputConsumer does not implement consumeError(). In the next version I will add a class ArrayListErrorConsumer. I hope I will find some time after Christmas to implement this and a few other additions, so you should have a working version beginning of next year.

    Bernhard

     
  • niki

    niki - 2012-12-14

    How could i get access to TestCase24.java in src/org/im4java/test, could you send me the url.

    Thanks

     
  • niki

    niki - 2012-12-14

    I tried to cmd.setErrorConsumer(output) where output is an instance of ArrayListOutputConsumer, but that did not work

     
  • PShah

    PShah - 2014-03-28

    Hi niki,
    Did this work for you? I am trying to achieve something similar and having same issue as you.

    Thanks,
    PShah

     
  • Bernhard Bablok

    Bernhard Bablok - 2014-03-29

    Hi,

    please have a look at src/org/im4java/test/TestCase24.java. The file is in the source-distribution. You have to define an ArrayListErrorConsumer and use CompareCommand.setErrorConsumer(...).

    Bernhard

     
  • PShah

    PShah - 2014-04-01

    I did this .. But I am not able to get value of compare. Basically, I want to get the metric value into a variable before proceeding further.

    CompareCmd compare = new CompareCmd();
    ArrayListErrorConsumer arryListCon = new ArrayListErrorConsumer();
    compare.setErrorConsumer(arryListCon);

    MOperation cmpOp = new IMOperation();
    cmpOp.addImage();
    cmpOp.addImage();
    cmpOp.metric("AE");
    cmpOp.addImage();

    compare.run(cmpOp, getScreenshotDir+ "/MIFF-"+nonBaseImg,
    getScreenshotDir+ "/MIFF-"+baseImg,
    getScreenshotDir+ "/MIFF-"+nonBaseImg+"__diff");

    ArrayList<string> cmdOP = arryListCon.getOutput();</string>

    for (String line : cmdOP) {
    log.info("----------> "+line);
    }

     

Log in to post a comment.

MongoDB Logo MongoDB