0
我有兩個圖像I-1和I-2,我可以使用im4java成功比較這兩個圖像。不過現在我-1和I-2具有不同的尺寸,因此當我嘗試這兩個圖像也沒有對它們進行比較比較,並給出消息如何使用im4java比較不同大小的圖像
例如: org.im4java.core.CommandException:org.im4java。 core.CommandException:compare.exe:圖像寬度或高度不同`C:\ Users \ hp \ workspace-getlinks-multipurpose \ links_extractor/snapshots/actuals/id-dashboard.jpg'@ error/compare.c/CompareImageCommand/990。
以下是我的代碼:
public static boolean compareImages(String exp, String cur,String output) {
// This instance wraps the compare command
CompareCmd compare = new CompareCmd();
// For metric-output
//compare.setErrorConsumer(StandardStream.STDERR);
IMOperation cmpOp = new IMOperation();
// Set the compare metric
cmpOp.metric("mae");
// cmpOp.addSubOperation(subimageSearch());
// Add the expected image
cmpOp.addImage(exp);
// Add the current image
cmpOp.addImage(cur);
// This stores the difference
cmpOp.addImage(output);
try {
// Do the compare
compare.run(cmpOp);
return true;
} catch (Exception ex) {
System.out.println("ex: "+ex);
return false;
}
}
我也做了一些RND我可以看到像submamage-search可以從imageMagik + cmd提示符使用的東西** compare -metric rmse -subimage-search image2.png image1.png cmp.png ** – Pawan