Commit 43097c6a authored by Kirill Kornyakov's avatar Kirill Kornyakov

lena added

parent 1649c8f6
...@@ -4,6 +4,7 @@ import java.io.FileOutputStream; ...@@ -4,6 +4,7 @@ import java.io.FileOutputStream;
import org.opencv.Mat; import org.opencv.Mat;
import org.opencv.core; import org.opencv.core;
import org.opencv.highgui;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -19,6 +20,11 @@ public class OpenCVTestCase extends AndroidTestCase { ...@@ -19,6 +20,11 @@ public class OpenCVTestCase extends AndroidTestCase {
static int matSize = 10; static int matSize = 10;
//Naming notation: channels_[type]_[dimension]_value
//examples: gray0 - single channel 8U 2d Mat filled with 0
// grayRnd - single channel 8U 2d Mat filled with random numbers
// gray0_32f_1d - refactor ;)
static Mat gray0; static Mat gray0;
static Mat gray1; static Mat gray1;
static Mat gray2; static Mat gray2;
...@@ -43,19 +49,14 @@ public class OpenCVTestCase extends AndroidTestCase { ...@@ -43,19 +49,14 @@ public class OpenCVTestCase extends AndroidTestCase {
static Mat rgba0; static Mat rgba0;
static Mat rgba128; static Mat rgba128;
static Mat dst_gray; static Mat rgbLena;
static Mat dst_gray_32f;
static Mat dst;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
// Log.e(TAG, "setUp");
super.setUp(); super.setUp();
//Naming notation: channels_[type]_[dimension]_value
//examples: gray0 - single channel 8U 2d Mat filled with 0
// grayRnd - single channel 8U 2d Mat filled with random numbers
// gray0_32f_1d - refactor ;)
gray0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray0.setTo(0.0); gray0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray0.setTo(0.0);
gray1 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray1.setTo(1.0); gray1 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray1.setTo(1.0);
gray2 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray2.setTo(2.0); gray2 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray2.setTo(2.0);
...@@ -93,10 +94,10 @@ public class OpenCVTestCase extends AndroidTestCase { ...@@ -93,10 +94,10 @@ public class OpenCVTestCase extends AndroidTestCase {
Log.e(TAG, "Tried to write lena.jpg, but: " + e.toString()); Log.e(TAG, "Tried to write lena.jpg, but: " + e.toString());
} }
dst_gray = new Mat(); rgbLena = highgui.imread(LENA);
assertTrue(dst_gray.empty());
dst_gray_32f = new Mat(); dst = new Mat();
assertTrue(dst_gray_32f.empty()); assertTrue(dst.empty());
} }
public static void assertMatEqual(Mat m1, Mat m2) { public static void assertMatEqual(Mat m1, Mat m2) {
......
...@@ -19,12 +19,12 @@ public class coreTest extends OpenCVTestCase { ...@@ -19,12 +19,12 @@ public class coreTest extends OpenCVTestCase {
Mat lut = new Mat(1, 256, Mat.CvType.CV_8UC1); Mat lut = new Mat(1, 256, Mat.CvType.CV_8UC1);
lut.setTo(0); lut.setTo(0);
core.LUT(grayRnd, lut, dst_gray); core.LUT(grayRnd, lut, dst);
assertMatEqual(gray0, dst_gray); assertMatEqual(gray0, dst);
lut.setTo(255); lut.setTo(255);
core.LUT(grayRnd, lut, dst_gray); core.LUT(grayRnd, lut, dst);
assertMatEqual(gray255, dst_gray); assertMatEqual(gray255, dst);
} }
public void testMahalanobis() { public void testMahalanobis() {
...@@ -45,8 +45,8 @@ public class coreTest extends OpenCVTestCase { ...@@ -45,8 +45,8 @@ public class coreTest extends OpenCVTestCase {
} }
public void testAbsdiff() { public void testAbsdiff() {
core.absdiff(gray128, gray255, dst_gray); core.absdiff(gray128, gray255, dst);
assertMatEqual(gray127, dst_gray); assertMatEqual(gray127, dst);
} }
public void testAddMatMatMatMatInt() { public void testAddMatMatMatMatInt() {
...@@ -58,8 +58,8 @@ public class coreTest extends OpenCVTestCase { ...@@ -58,8 +58,8 @@ public class coreTest extends OpenCVTestCase {
} }
public void testAddMatMatMat() { public void testAddMatMatMat() {
core.add(gray128, gray128, dst_gray); core.add(gray128, gray128, dst);
assertMatEqual(gray255, dst_gray); assertMatEqual(gray255, dst);
} }
public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() { public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() {
...@@ -69,8 +69,8 @@ public class coreTest extends OpenCVTestCase { ...@@ -69,8 +69,8 @@ public class coreTest extends OpenCVTestCase {
} }
public void testAddWeightedMatDoubleMatDoubleDoubleMat() { public void testAddWeightedMatDoubleMatDoubleDoubleMat() {
core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst_gray); core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst);
assertMatEqual(gray255, dst_gray); assertMatEqual(gray255, dst);
} }
public void testBitwise_andMatMatMatMat() { public void testBitwise_andMatMatMatMat() {
...@@ -78,8 +78,8 @@ public class coreTest extends OpenCVTestCase { ...@@ -78,8 +78,8 @@ public class coreTest extends OpenCVTestCase {
} }
public void testBitwise_andMatMatMat() { public void testBitwise_andMatMatMat() {
core.bitwise_and(gray3, gray2, dst_gray); core.bitwise_and(gray3, gray2, dst);
assertMatEqual(gray2, dst_gray); assertMatEqual(gray2, dst);
} }
public void testBitwise_notMatMatMat() { public void testBitwise_notMatMatMat() {
...@@ -177,14 +177,14 @@ public class coreTest extends OpenCVTestCase { ...@@ -177,14 +177,14 @@ public class coreTest extends OpenCVTestCase {
public void testCompleteSymmMatBoolean() { public void testCompleteSymmMatBoolean() {
core.completeSymm(grayRnd_32f, true); core.completeSymm(grayRnd_32f, true);
core.transpose(grayRnd_32f, dst_gray_32f); core.transpose(grayRnd_32f, dst);
assertMatEqual(grayRnd_32f, dst_gray_32f); assertMatEqual(grayRnd_32f, dst);
} }
public void testCompleteSymmMat() { public void testCompleteSymmMat() {
core.completeSymm(grayRnd_32f); core.completeSymm(grayRnd_32f);
core.transpose(grayRnd_32f, dst_gray_32f); core.transpose(grayRnd_32f, dst);
assertMatEqual(grayRnd_32f, dst_gray_32f); assertMatEqual(grayRnd_32f, dst);
} }
public void testConvertScaleAbsMatMatDoubleDouble() { public void testConvertScaleAbsMatMatDoubleDouble() {
...@@ -215,15 +215,15 @@ public class coreTest extends OpenCVTestCase { ...@@ -215,15 +215,15 @@ public class coreTest extends OpenCVTestCase {
} }
public void testDctMatMat() { public void testDctMatMat() {
core.dct(gray0_32f_1d, dst_gray); core.dct(gray0_32f_1d, dst);
assertMatEqual(gray0_32f_1d, dst_gray); assertMatEqual(gray0_32f_1d, dst);
Mat in = new Mat(1, 4, Mat.CvType.CV_32FC1); Mat in = new Mat(1, 4, Mat.CvType.CV_32FC1);
in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682); in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682);
Mat out = new Mat(1, 4, Mat.CvType.CV_32FC1); Mat out = new Mat(1, 4, Mat.CvType.CV_32FC1);
out.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477); out.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477);
core.dct(in, dst_gray); core.dct(in, dst);
assertMatEqual(out, dst_gray); assertMatEqual(out, dst);
} }
public void testDeterminant() { public void testDeterminant() {
...@@ -283,8 +283,8 @@ public class coreTest extends OpenCVTestCase { ...@@ -283,8 +283,8 @@ public class coreTest extends OpenCVTestCase {
} }
public void testExtractChannel() { public void testExtractChannel() {
core.extractChannel(rgba128, dst_gray, 0); core.extractChannel(rgba128, dst, 0);
assertMatEqual(gray128, dst_gray); assertMatEqual(gray128, dst);
} }
public void testFastAtan2() { public void testFastAtan2() {
...@@ -317,9 +317,9 @@ public class coreTest extends OpenCVTestCase { ...@@ -317,9 +317,9 @@ public class coreTest extends OpenCVTestCase {
Mat eConcat = new Mat(1, 9, Mat.CvType.CV_8UC1); Mat eConcat = new Mat(1, 9, Mat.CvType.CV_8UC1);
e.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); e.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1);
eConcat.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); eConcat.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1);
core.hconcat(e, dst_gray); core.hconcat(e, dst);
assertMatEqual(eConcat, dst_gray); assertMatEqual(eConcat, dst);
} }
public void testIdctMatMatInt() { public void testIdctMatMatInt() {
...@@ -428,13 +428,13 @@ public class coreTest extends OpenCVTestCase { ...@@ -428,13 +428,13 @@ public class coreTest extends OpenCVTestCase {
} }
public void testMulTransposedMatMatBooleanMat() { public void testMulTransposedMatMatBooleanMat() {
core.mulTransposed(grayRnd_32f, dst_gray_32f, true, grayRnd_32f); core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f);
assertMatEqual(gray0_32f, dst_gray_32f); assertMatEqual(gray0_32f, dst);
} }
public void testMulTransposedMatMatBoolean() { public void testMulTransposedMatMatBoolean() {
core.mulTransposed(grayE_32f, dst_gray_32f, true); core.mulTransposed(grayE_32f, dst, true);
assertMatEqual(grayE_32f, dst_gray_32f); assertMatEqual(grayE_32f, dst);
} }
public void testMultiplyMatMatMatDoubleInt() { public void testMultiplyMatMatMatDoubleInt() {
......
...@@ -40,15 +40,19 @@ public class highguiTest extends OpenCVTestCase { ...@@ -40,15 +40,19 @@ public class highguiTest extends OpenCVTestCase {
} }
public void testImreadStringInt() { public void testImreadStringInt() {
dst_gray = highgui.imread(LENA, 0); dst = highgui.imread(LENA, 0);
assertTrue(!dst_gray.empty()); assertTrue(!dst.empty());
assertEquals(1, dst_gray.channels()); assertEquals(1, dst.channels());
assertTrue(512 == dst.cols());
assertTrue(512 == dst.rows());
} }
public void testImreadString() { public void testImreadString() {
dst_gray = highgui.imread(LENA); dst = highgui.imread(LENA);
assertTrue(!dst_gray.empty()); assertTrue(!dst.empty());
assertEquals(3, dst_gray.channels()); assertEquals(3, dst.channels());
assertTrue(512 == dst.cols());
assertTrue(512 == dst.rows());
} }
public void testImshow() { public void testImshow() {
......
...@@ -200,11 +200,11 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -200,11 +200,11 @@ public class imgprocTest extends OpenCVTestCase {
public void testBlurMatMatSize() { public void testBlurMatMatSize() {
Size sz = new Size(3, 3); Size sz = new Size(3, 3);
imgproc.blur(gray0, dst_gray, sz); imgproc.blur(gray0, dst, sz);
assertMatEqual(gray0, dst_gray); assertMatEqual(gray0, dst);
imgproc.blur(gray255, dst_gray, sz); imgproc.blur(gray255, dst, sz);
assertMatEqual(gray255, dst_gray); assertMatEqual(gray255, dst);
} }
public void testBorderInterpolate() { public void testBorderInterpolate() {
...@@ -225,8 +225,8 @@ public class imgprocTest extends OpenCVTestCase { ...@@ -225,8 +225,8 @@ public class imgprocTest extends OpenCVTestCase {
public void testBoxFilterMatMatIntSize() { public void testBoxFilterMatMatIntSize() {
Size sz = new Size(3, 3); Size sz = new Size(3, 3);
imgproc.boxFilter(gray0, dst_gray, 8, sz); imgproc.boxFilter(gray0, dst, 8, sz);
assertMatEqual(gray0, dst_gray); assertMatEqual(gray0, dst);
} }
public void testCompareHist() { public void testCompareHist() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment