統合テスト中に 2 つの画像の違いを特定しようとしています。Web でいくつかの調査を行った後、MarvinProject に出くわし、それを使用してUnitTestを作成しようとしました。以下を参照してください。
私がプラグインを理解している限り、それは違いを含む領域でDifferentRegions
渡されたものを埋めます。ImageMask differenceMask
テストに渡す 2 つの画像は異なるため、何かが出力されるはずです。
残念ながらそうではありません。
これらの 2 つのイメージをバイト単位で比較し、それらが成功する他のテストを作成しました。この問題を試してみたい方のために、GitHub にリポジトリを作成しました。ここに ImageCompareTestがあります。
@Test
public void tryMarvinProject() {
// init images
String root = "src/test/resources/";
MarvinImage assertedImg = MarvinImageIO.loadImage(root + "image1.bmp");
MarvinImage actualImg = MarvinImageIO.loadImage(root + "image2.bmp");
// init diff-regions plugin
DifferentRegions regions = new DifferentRegions();
regions.load();
regions.setAttribute("comparisonImage", assertedImg);
int width = assertedImg.getWidth();
int height = assertedImg.getHeight();
int type = assertedImg.getType();
// process the images and retrieve differences from the ImageMask
MarvinImageMask differenceMask = new MarvinImageMask();
regions.process(
actualImg,
new MarvinImage(new BufferedImage(width, height, type)),
new MarvinAttributes(),
differenceMask,
false);
// should contain the differences, but does not
System.out.println(differenceMask.getMaskArray());
assertNotNull(differenceMask.getMaskArray());
}