ImageConverter { public Image convert(MatWrapper wrapper) { return convert(wrapper.getCpu()); }  Image convert(MatWrapper wrapper); Image convert(Mat mat);  }
@Test(expected = IllegalStateException.class) public void testConvertInWrongThreadThrowsIllegalState() { converter.convert(new Mat()); }
@Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") public void testConvertImageSwitch() throws Exception { Mat gompeiMat = new Mat(); Mat imageMat = new Mat(); ImageLoadingUtility.loadImage( URLDecoder.decode(Paths.get(gompeiImage.file.toURI()).toString(), StandardCharsets.UTF_8.name()), gompeiMat); ImageLoadingUtility.loadImage( URLDecoder.decode(Paths.get(imageFile.file.toURI()).toString(), StandardCharsets.UTF_8.name()), imageMat); interact(() -> { converter.convert(gompeiMat); Image javaFXImage = converter.convert(imageMat); assertSameImage(imageFile, javaFXImage); }); }
@Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") public void testConvertSingleChanelImage() throws Exception { final Mat gompeiMat = new Mat(); ImageLoadingUtility.loadImage( URLDecoder.decode(Paths.get(gompeiImage.file.toURI()).toString(), StandardCharsets.UTF_8.name()), gompeiMat); final Mat desaturatedMat = new Mat(); cvtColor(gompeiMat, desaturatedMat, COLOR_BGR2GRAY); interact(() -> { Image javaFXImage = converter.convert(desaturatedMat); assertSameImage(gompeiImage, javaFXImage); }); }
@Test @SuppressWarnings("PMD.JUnitTestsShouldIncludeAssert") public void testConvertImage() throws Exception { Mat mat = new Mat(); ImageLoadingUtility.loadImage( URLDecoder.decode(Paths.get(gompeiImage.file.toURI()).toString(), StandardCharsets.UTF_8.name()), mat); interact(() -> { Image javaFXImage = converter.convert(mat); assertSameImage(gompeiImage, javaFXImage); }); }