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(),
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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(),
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
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
How could i get access to TestCase24.java in src/org/im4java/test, could you send me the url.
Thanks
I tried to cmd.setErrorConsumer(output) where output is an instance of ArrayListOutputConsumer, but that did not work
Hi niki,
Did this work for you? I am trying to achieve something similar and having same issue as you.
Thanks,
PShah
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
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);
}