From 2ec0efaae51a6e5ef93aa553fe78fb04e8b3a2a1 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Thu, 19 Apr 2012 15:01:19 +0000 Subject: [PATCH] fixing stability of testBitmapToMat() --- .../java/android_test/src/org/opencv/test/android/UtilsTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/android/UtilsTest.java b/modules/java/android_test/src/org/opencv/test/android/UtilsTest.java index 8c9b2b7..8977dca 100644 --- a/modules/java/android_test/src/org/opencv/test/android/UtilsTest.java +++ b/modules/java/android_test/src/org/opencv/test/android/UtilsTest.java @@ -23,10 +23,12 @@ public class UtilsTest extends OpenCVTestCase { Bitmap bmp16 = BitmapFactory.decodeFile(OpenCVTestRunner.LENA_PATH, opt16); Mat m16 = new Mat(); Utils.bitmapToMat(bmp16, m16); + assertTrue(m16.rows() == 512 && m16.cols() == 512 && m16.type() == CvType.CV_8UC4); - BitmapFactory.Options opt32 = new BitmapFactory.Options(); + /*BitmapFactory.Options opt32 = new BitmapFactory.Options(); opt32.inPreferredConfig = Bitmap.Config.ARGB_8888; - Bitmap bmp32 = BitmapFactory.decodeFile(OpenCVTestRunner.LENA_PATH, opt32); + Bitmap bmp32 = BitmapFactory.decodeFile(OpenCVTestRunner.LENA_PATH, opt32);*/ + Bitmap bmp32 = bmp16.copy(Bitmap.Config.ARGB_8888, false); Mat m32 = new Mat(); Utils.bitmapToMat(bmp32, m32); @@ -34,6 +36,7 @@ public class UtilsTest extends OpenCVTestCase { double maxDiff = Core.norm(m16, m32, Core.NORM_INF); Log.d("Bmp->Mat", "bmp16->Mat vs bmp32->Mat diff = " + maxDiff); + assertTrue(maxDiff <= 8 /* 8 == 2^8 / 2^5 */); } -- 2.7.4