diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
index 2f3aa2b8e..a83c7017b 100644
--- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
+++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst
@@ -915,7 +915,7 @@ Reprojects a disparity image to 3D space.
.. ocv:cfunction:: void cvReprojectImageTo3D( const CvArr* disparity, CvArr* _3dImage, const CvMat* Q, int handleMissingValues=0)
.. ocv:pyoldfunction:: cv.ReprojectImageTo3D(disparity, _3dImage, Q, handleMissingValues=0) -> None
- :param disparity: Input single-channel 16-bit signed or 32-bit floating-point disparity image.
+ :param disparity: Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit floating-point disparity image.
:param _3dImage: Output 3-channel floating-point image of the same size as ``disparity`` . Each element of ``_3dImage(x,y)`` contains 3D coordinates of the point ``(x,y)`` computed from the disparity map.
diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
index 91f8fabd1..35246030f 100644
--- a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
+++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
@@ -115,6 +115,44 @@ public class OpenCVTestCase extends TestCase {
v1.put(0, 0, 1.0, 3.0, 2.0);
v2 = new Mat(1, 3, CvType.CV_32F);
v2.put(0, 0, 2.0, 1.0, 3.0);
+
+ low.release();
+ high.release();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+
+ gray0.release();
+ gray1.release();
+ gray2.release();
+ gray3.release();
+ gray9.release();
+ gray127.release();
+ gray128.release();
+ gray255.release();
+ gray_16u_256.release();
+ gray_16s_1024.release();
+ grayRnd.release();
+ gray0_32f.release();
+ gray1_32f.release();
+ gray3_32f.release();
+ gray9_32f.release();
+ gray255_32f.release();
+ grayE_32f.release();
+ grayE_32f.release();
+ grayRnd_32f.release();
+ gray0_32f_1d.release();
+ gray0_64f.release();
+ gray0_64f_1d.release();
+ rgba0.release();
+ rgba128.release();
+ rgbLena.release();
+ grayChess.release();
+ v1.release();
+ v2.release();
+
+ super.tearDown();
}
public static void assertMatEqual(Mat m1, Mat m2) {
@@ -133,30 +171,31 @@ public class OpenCVTestCase extends TestCase {
compareMats(expected, actual, eps, false);
}
- static private void compareMats(Mat m1, Mat m2, boolean isEqualityMeasured) {
- // OpenCVTestRunner.Log(m1.toString());
- // OpenCVTestRunner.Log(m2.toString());
-
- if (m1.type() != m2.type() || m1.cols() != m2.cols()
- || m1.rows() != m2.rows()) {
+ static private void compareMats(Mat expected, Mat actual, boolean isEqualityMeasured) {
+ if (expected.type() != actual.type() || expected.cols() != actual.cols()
+ || expected.rows() != actual.rows()) {
throw new UnsupportedOperationException();
- } else if (m1.channels() == 1) {
- if (isEqualityMeasured) {
- assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0);
- } else {
- assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0);
- }
- } else {
- for (int coi = 0; coi < m1.channels(); coi++) {
- Mat m1c = getCOI(m1, coi);
- Mat m2c = getCOI(m2, coi);
- if (isEqualityMeasured) {
- assertTrue(CalcPercentageOfDifference(m1c, m2c) == 0.0);
- } else {
- assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0);
- }
- }
}
+
+ if (expected.depth() == CvType.CV_32F || expected.depth() == CvType.CV_64F){
+ if (isEqualityMeasured)
+ throw new UnsupportedOperationException("Floating-point Mats must not be checked for exact match. Use assertMatEqual(Mat expected, Mat actual, double eps) instead.");
+ else
+ throw new UnsupportedOperationException("Floating-point Mats must not be checked for exact match. Use assertMatNotEqual(Mat expected, Mat actual, double eps) instead.");
+ }
+
+ Mat diff = new Mat();
+ Core.absdiff(expected, actual, diff);
+ Mat reshaped = diff.reshape(1);
+ int mistakes = Core.countNonZero(reshaped);
+
+ reshaped.release();
+ diff.release();
+
+ if(isEqualityMeasured)
+ assertTrue("Mats are different in " + mistakes + " points", 0 == mistakes);
+ else
+ assertFalse("Mats are equal", 0 == mistakes);
}
static private void compareMats(Mat expected, Mat actual, double eps, boolean isEqualityMeasured) {
@@ -167,34 +206,13 @@ public class OpenCVTestCase extends TestCase {
Mat diff = new Mat();
Core.absdiff(expected, actual, diff);
if(isEqualityMeasured)
- assertTrue("Max difference between expected and actiual values is bigger than " + eps,
+ assertTrue("Max difference between expected and actiual Mats is bigger than " + eps,
Core.checkRange(diff, true, new Point(), 0.0, eps));
else
- assertFalse("Max difference between expected and actiual values is less than " + eps,
+ assertFalse("Max difference between expected and actiual Mats is less than " + eps,
Core.checkRange(diff, true, new Point(), 0.0, eps));
}
- static private Mat getCOI(Mat m, int coi) {
- Mat ch = new Mat(m.rows(), m.cols(), m.depth());
-
- for (int i = 0; i < m.rows(); i++)
- for (int j = 0; j < m.cols(); j++) {
- double pixel[] = m.get(i, j);
- ch.put(i, j, pixel[coi]);
- }
-
- return ch;
- }
-
- static private double CalcPercentageOfDifference(Mat m1, Mat m2) {
- Mat cmp = new Mat(0, 0, CvType.CV_8U);
- Core.compare(m1, m2, cmp, Core.CMP_EQ);
- double difference = 100.0 * (1.0 - Double.valueOf(Core
- .countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols()));
-
- return difference;
- }
-
public void test_1(String label) {
OpenCVTestRunner
.Log("================================================");
diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
index df46ac7e7..9249ac36d 100644
--- a/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
+++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestRunner.java
@@ -1,64 +1,78 @@
package org.opencv.test;
-import java.io.FileOutputStream;
-
import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-import android.graphics.BitmapFactory;
import android.test.AndroidTestRunner;
import android.test.InstrumentationTestRunner;
import android.util.Log;
-/**
- * This only class is Android specific.
- * The original idea about test order randomization is from marek.defecinski blog.
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * This only class is Android specific. The original idea about test order
+ * randomization is from marek.defecinski blog.
*
* @see OpenCV
- */
+ */
public class OpenCVTestRunner extends InstrumentationTestRunner {
-
- public static String LENA_PATH = "/data/data/org.opencv.test/files/lena.jpg";
- public static String CHESS_PATH = "/data/data/org.opencv.test/files/chessboard.jpg";
- public static String LBPCASCADE_FRONTALFACE_PATH = "/mnt/sdcard/lbpcascade_frontalface.xml";
+
+ public static String LENA_PATH;
+ public static String CHESS_PATH;
+ public static String LBPCASCADE_FRONTALFACE_PATH;
+
+ private AndroidTestRunner androidTestRunner;
+ private static String TAG = "opencv_test_java";
+
+ static public void Log(String message) {
+ Log.e(TAG, message);
+ }
- private AndroidTestRunner androidTestRunner;
- private static String TAG = "opencv_test_java";
-
- static public void Log(String message) {
- Log.e(TAG, message);
- }
-
- @Override
+ @Override
public void onStart() {
- ExportResourceImage("lena.jpg", R.drawable.lena);
- ExportResourceImage("chessboard.jpg", R.drawable.chessboard);
-
- //FIXME: implement export of the cascade
-
- //List testCases = androidTestRunner.getTestCases();
- //Collections.shuffle(testCases); //shuffle the tests order
-
+ LENA_PATH = ExportResource(R.drawable.lena);
+ CHESS_PATH = ExportResource(R.drawable.chessboard);
+ LBPCASCADE_FRONTALFACE_PATH = ExportResource(R.raw.lbpcascade_frontalface);
+
+ // List testCases = androidTestRunner.getTestCases();
+ // Collections.shuffle(testCases); //shuffle the tests order
+
super.onStart();
}
-
- @Override
- protected AndroidTestRunner getAndroidTestRunner() {
- androidTestRunner = super.getAndroidTestRunner();
- return androidTestRunner;
+
+ @Override
+ protected AndroidTestRunner getAndroidTestRunner() {
+ androidTestRunner = super.getAndroidTestRunner();
+ return androidTestRunner;
+ }
+
+ private String ExportResource(int resourceId) {
+ String fullname = getContext().getResources().getString(resourceId);
+ String resName = fullname.substring(fullname.lastIndexOf("/") + 1);
+ try {
+ InputStream is = getContext().getResources().openRawResource(
+ resourceId);
+ File resDir = getContext().getDir("testdata", Context.MODE_PRIVATE);
+ File resFile = new File(resDir, resName);
+
+ FileOutputStream os = new FileOutputStream(resFile);
+
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = is.read(buffer)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ is.close();
+ os.close();
+
+ return resFile.getAbsolutePath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ Log("Failed to export resource " + resName + ". Exception thrown: "
+ + e);
+ }
+ return null;
}
-
- private void ExportResourceImage(String image, int rId) {
- try {
- Bitmap mBitmap = BitmapFactory.decodeResource(this.getContext().getResources(), rId);
- FileOutputStream fos = this.getContext().openFileOutput(image, Context.MODE_WORLD_READABLE);
- mBitmap.compress(CompressFormat.JPEG, 100, fos);
- fos.flush();
- fos.close();
- }
- catch (Exception e) {
- Log("Tried to write " + image + ", but: " + e.toString());
- }
- }
}
diff --git a/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java b/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java
index 53b93c41d..3ac115e3f 100644
--- a/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java
+++ b/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java
@@ -52,8 +52,8 @@ public class calib3dTest extends OpenCVTestCase {
Calib3d.composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3);
- assertMatEqual(outRvec, rvec3);
- assertMatEqual(outTvec, tvec3);
+ assertMatEqual(outRvec, rvec3, EPS);
+ assertMatEqual(outTvec, tvec3, EPS);
}
public void testComposeRTMatMatMatMatMatMatMat() {
@@ -367,15 +367,122 @@ public class calib3dTest extends OpenCVTestCase {
}
public void testReprojectImageTo3DMatMatMat() {
- fail("Not yet implemented");
+ Mat transformMatrix = new Mat(4,4,CvType.CV_64F);
+ transformMatrix.put(0, 0,
+ 0, 1, 0, 0,
+ 1, 0, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+
+ Mat disparity = new Mat(matSize,matSize,CvType.CV_32F);
+
+ float[] disp = new float[matSize * matSize];
+ for (int i = 0; i < matSize; i++)
+ for(int j = 0; j < matSize; j++)
+ disp[i * matSize + j] = i - j;
+ disparity.put(0, 0, disp);
+
+ Mat _3dPoints = new Mat();
+
+ Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix);
+
+ assertEquals(CvType.CV_32FC3, _3dPoints.type());
+ assertEquals(matSize, _3dPoints.rows());
+ assertEquals(matSize, _3dPoints.cols());
+
+ truth = new Mat(matSize,matSize,CvType.CV_32FC3);
+
+ float[] _truth = new float[matSize * matSize * 3];
+ for (int i = 0; i < matSize; i++)
+ for(int j = 0; j < matSize; j++)
+ {
+ _truth[(i * matSize + j) * 3 + 0] = i;
+ _truth[(i * matSize + j) * 3 + 1] = j;
+ _truth[(i * matSize + j) * 3 + 2] = i-j;
+ }
+ truth.put(0, 0, _truth);
+
+ assertMatEqual(truth, _3dPoints, EPS);
}
public void testReprojectImageTo3DMatMatMatBoolean() {
- fail("Not yet implemented");
+ Mat transformMatrix = new Mat(4,4,CvType.CV_64F);
+ transformMatrix.put(0, 0,
+ 0, 1, 0, 0,
+ 1, 0, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+
+ Mat disparity = new Mat(matSize,matSize,CvType.CV_32F);
+
+ float[] disp = new float[matSize * matSize];
+ for (int i = 0; i < matSize; i++)
+ for(int j = 0; j < matSize; j++)
+ disp[i * matSize + j] = i - j;
+ disp[0] = -Float.MAX_VALUE;
+ disparity.put(0, 0, disp);
+
+ Mat _3dPoints = new Mat();
+
+ Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, true);
+
+ assertEquals(CvType.CV_32FC3, _3dPoints.type());
+ assertEquals(matSize, _3dPoints.rows());
+ assertEquals(matSize, _3dPoints.cols());
+
+ truth = new Mat(matSize,matSize,CvType.CV_32FC3);
+
+ float[] _truth = new float[matSize * matSize * 3];
+ for (int i = 0; i < matSize; i++)
+ for(int j = 0; j < matSize; j++)
+ {
+ _truth[(i * matSize + j) * 3 + 0] = i;
+ _truth[(i * matSize + j) * 3 + 1] = j;
+ _truth[(i * matSize + j) * 3 + 2] = i-j;
+ }
+ _truth[2] = 10000;
+ truth.put(0, 0, _truth);
+
+ assertMatEqual(truth, _3dPoints, EPS);
}
public void testReprojectImageTo3DMatMatMatBooleanInt() {
- fail("Not yet implemented");
+ Mat transformMatrix = new Mat(4,4,CvType.CV_64F);
+ transformMatrix.put(0, 0,
+ 0, 1, 0, 0,
+ 1, 0, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1);
+
+ Mat disparity = new Mat(matSize,matSize,CvType.CV_32F);
+
+ float[] disp = new float[matSize * matSize];
+ for (int i = 0; i < matSize; i++)
+ for(int j = 0; j < matSize; j++)
+ disp[i * matSize + j] = i - j;
+ disparity.put(0, 0, disp);
+
+ Mat _3dPoints = new Mat();
+
+ Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, false, CvType.CV_16S);
+
+ assertEquals(CvType.CV_16SC3, _3dPoints.type());
+ assertEquals(matSize, _3dPoints.rows());
+ assertEquals(matSize, _3dPoints.cols());
+
+ truth = new Mat(matSize,matSize,CvType.CV_16SC3);
+
+ short[] _truth = new short[matSize * matSize * 3];
+ for (short i = 0; i < matSize; i++)
+ for(short j = 0; j < matSize; j++)
+ {
+ _truth[(i * matSize + j) * 3 + 0] = i;
+ _truth[(i * matSize + j) * 3 + 1] = j;
+ _truth[(i * matSize + j) * 3 + 2] = (short) (i-j);
+ }
+ truth.put(0, 0, _truth);
+
+ assertMatEqual(truth, _3dPoints, EPS);
}
public void testRodriguesMatMat() {
diff --git a/modules/java/android_test/src/org/opencv/test/core/MatTest.java b/modules/java/android_test/src/org/opencv/test/core/MatTest.java
index 67ed0edd6..1f10faa07 100644
--- a/modules/java/android_test/src/org/opencv/test/core/MatTest.java
+++ b/modules/java/android_test/src/org/opencv/test/core/MatTest.java
@@ -6,253 +6,257 @@ import org.opencv.core.Scalar;
import org.opencv.test.OpenCVTestCase;
public class MatTest extends OpenCVTestCase {
-
- public void test_1() {
- super.test_1("Mat");
- }
- public void testChannels() {
- assertEquals(1, gray0.channels());
- assertEquals(3, rgbLena.channels());
- assertEquals(4, rgba0.channels());
- }
+ public void test_1() {
+ super.test_1("Mat");
+ }
- public void testClone() {
- dst = gray0.clone();
- assertMatEqual(gray0, dst);
- }
+ public void testChannels() {
+ assertEquals(1, gray0.channels());
+ assertEquals(3, rgbLena.channels());
+ assertEquals(4, rgba0.channels());
+ }
- public void testCol() {
- Mat col = gray0.col(0);
- assertEquals(1, col.cols());
- assertEquals(gray0.rows(), col.rows());
- }
+ public void testClone() {
+ dst = gray0.clone();
+ assertMatEqual(gray0, dst);
+ }
- public void testColRange() {
- Mat cols = gray0.colRange(0, gray0.cols()/2);
- assertEquals(gray0.cols()/2, cols.cols());
- assertEquals(gray0.rows(), cols.rows());
- }
+ public void testCol() {
+ Mat col = gray0.col(0);
+ assertEquals(1, col.cols());
+ assertEquals(gray0.rows(), col.rows());
+ }
- public void testCols() {
- assertEquals(matSize, gray0.rows());
- }
+ public void testColRange() {
+ Mat cols = gray0.colRange(0, gray0.cols() / 2);
+ assertEquals(gray0.cols() / 2, cols.cols());
+ assertEquals(gray0.rows(), cols.rows());
+ }
- public void testCopyTo() {
- rgbLena.copyTo(dst);
- assertMatEqual(rgbLena, dst);
- }
+ public void testCols() {
+ assertEquals(matSize, gray0.rows());
+ }
- public void testCross() {
- Mat answer = new Mat(1, 3, CvType.CV_32F);
- answer.put(0, 0, 7.0, 1.0, -5.0);
-
- Mat cross = v1.cross(v2);
- assertMatEqual(answer, cross);
- }
+ public void testCopyTo() {
+ rgbLena.copyTo(dst);
+ assertMatEqual(rgbLena, dst);
+ }
- public void testDataAddr() {
- assertTrue(0 != gray0.dataAddr());
- }
+ public void testCross() {
+ Mat answer = new Mat(1, 3, CvType.CV_32F);
+ answer.put(0, 0, 7.0, 1.0, -5.0);
- public void testDepth() {
- assertEquals(CvType.CV_8U, gray0.depth());
- assertEquals(CvType.CV_32F, gray0_32f.depth());
- }
+ Mat cross = v1.cross(v2);
+ assertMatEqual(answer, cross, EPS);
+ }
- public void testRelease() {
- assertTrue( gray0.empty() == false );
- assertTrue( gray0.rows() > 0 );
- gray0.release();
- assertTrue( gray0.empty() == true );
- assertTrue( gray0.rows() == 0 );
- }
+ public void testDataAddr() {
+ assertTrue(0 != gray0.dataAddr());
+ }
- public void testDot() {
- double s = v1.dot(v2);
- assertEquals(11.0, s);
- }
-
- public void testDump() {
- assertEquals("[1, 3, 2]", v1.dump());
- }
+ public void testDepth() {
+ assertEquals(CvType.CV_8U, gray0.depth());
+ assertEquals(CvType.CV_32F, gray0_32f.depth());
+ }
- public void testElemSize() {
- assertEquals(1, gray0.elemSize());
- assertEquals(4, gray0_32f.elemSize());
- assertEquals(3, rgbLena.elemSize());
- }
+ public void testRelease() {
+ assertTrue(gray0.empty() == false);
+ assertTrue(gray0.rows() > 0);
+ gray0.release();
+ assertTrue(gray0.empty() == true);
+ assertTrue(gray0.rows() == 0);
+ }
- public void testEmpty() {
- assertTrue(dst.empty());
- assertTrue(!gray0.empty());
- }
-
- public void testEye() {
- Mat eye = Mat.eye(3, 3, CvType.CV_32FC1);
- assertMatEqual(eye, eye.inv());
- }
+ public void testDot() {
+ double s = v1.dot(v2);
+ assertEquals(11.0, s);
+ }
- public void testGetIntInt() {
- fail("Not yet implemented");
- }
+ public void testDump() {
+ assertEquals("[1, 3, 2]", v1.dump());
+ }
- public void testGetIntIntByteArray() {
- fail("Not yet implemented");
- }
+ public void testElemSize() {
+ assertEquals(1, gray0.elemSize());
+ assertEquals(4, gray0_32f.elemSize());
+ assertEquals(3, rgbLena.elemSize());
+ }
- public void testGetIntIntDoubleArray() {
- fail("Not yet implemented");
- }
+ public void testEmpty() {
+ assertTrue(dst.empty());
+ assertTrue(!gray0.empty());
+ }
- public void testGetIntIntFloatArray() {
- fail("Not yet implemented");
- }
+ public void testEye() {
+ Mat eye = Mat.eye(3, 3, CvType.CV_32FC1);
+ assertMatEqual(eye, eye.inv(), EPS);
+ }
- public void testGetIntIntIntArray() {
- fail("Not yet implemented");
- }
+ public void testGetIntInt() {
+ fail("Not yet implemented");
+ }
- public void testGetIntIntShortArray() {
- fail("Not yet implemented");
- }
+ public void testGetIntIntByteArray() {
+ fail("Not yet implemented");
+ }
- public void testGetNativeObjAddr() {
- assertTrue(0 != gray0.getNativeObjAddr());
- }
+ public void testGetIntIntDoubleArray() {
+ fail("Not yet implemented");
+ }
- public void testHeight() {
- assertEquals(gray0.rows(), gray0.height());
- assertEquals(rgbLena.rows(), rgbLena.height());
- assertEquals(rgba128.rows(), rgba128.height());
- }
+ public void testGetIntIntFloatArray() {
+ fail("Not yet implemented");
+ }
- public void testInv() {
- dst = grayE_32f.inv();
- assertMatEqual(grayE_32f, dst);
- }
+ public void testGetIntIntIntArray() {
+ fail("Not yet implemented");
+ }
- public void testIsContinuous() {
- assertTrue(gray0.isContinuous());
-
- Mat subMat = gray0.submat(0, 0, gray0.rows()/2, gray0.cols()/2);
- assertFalse(subMat.isContinuous());
- }
+ public void testGetIntIntShortArray() {
+ fail("Not yet implemented");
+ }
- public void testIsSubmatrix() {
- assertFalse(gray0.isSubmatrix());
- Mat subMat = gray0.submat(0, 0, gray0.rows()/2, gray0.cols()/2);
- assertTrue(subMat.isSubmatrix());
- }
-
- public void testMat() {
- Mat m = new Mat();
- assertTrue(null != m);
- assertTrue(m.empty());
- }
+ public void testGetNativeObjAddr() {
+ assertTrue(0 != gray0.getNativeObjAddr());
+ }
- public void testMatIntIntCvType() {
- Mat gray = new Mat(1, 1, CvType.CV_8UC1);
- assertFalse(gray.empty());
-
- Mat rgb = new Mat(1, 1, CvType.CV_8UC3);
- assertFalse(rgb.empty());
- }
+ public void testHeight() {
+ assertEquals(gray0.rows(), gray0.height());
+ assertEquals(rgbLena.rows(), rgbLena.height());
+ assertEquals(rgba128.rows(), rgba128.height());
+ }
- public void testMatIntIntCvTypeScalar() {
- dst = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(127));
- assertFalse(dst.empty());
- assertMatEqual(dst, gray127);
-
- dst = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, Scalar.all(128));
- assertFalse(dst.empty());
- assertMatEqual(dst, rgba128);
- }
+ public void testInv() {
+ dst = grayE_32f.inv();
+ assertMatEqual(grayE_32f, dst, EPS);
+ }
- public void testMatIntIntInt() {
- Mat gray = new Mat(1, 1, CvType.CV_8U);
- assertFalse(gray.empty());
-
- Mat rgb = new Mat(1, 1, CvType.CV_8U);
- assertFalse(rgb.empty());
- }
+ public void testIsContinuous() {
+ assertTrue(gray0.isContinuous());
- public void testMatIntIntIntScalar() {
- Mat m1 = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(127));
- assertFalse(m1.empty());
- assertMatEqual(m1, gray127);
-
- Mat m2 = new Mat(gray0_32f.rows(), gray0_32f.cols(), CvType.CV_32F, new Scalar(0));
- assertFalse(m2.empty());
- assertMatEqual(m2, gray0_32f);
- }
+ Mat subMat = gray0.submat(0, 0, gray0.rows() / 2, gray0.cols() / 2);
+ assertFalse(subMat.isContinuous());
+ }
- public void testPutIntIntByteArray() {
- fail("Not yet implemented");
- }
+ public void testIsSubmatrix() {
+ assertFalse(gray0.isSubmatrix());
+ Mat subMat = gray0.submat(0, 0, gray0.rows() / 2, gray0.cols() / 2);
+ assertTrue(subMat.isSubmatrix());
+ }
- public void testPutIntIntDoubleArray() {
- fail("Not yet implemented");
- }
+ public void testMat() {
+ Mat m = new Mat();
+ assertTrue(null != m);
+ assertTrue(m.empty());
+ }
- public void testPutIntIntFloatArray() {
- fail("Not yet implemented");
- }
+ public void testMatIntIntCvType() {
+ Mat gray = new Mat(1, 1, CvType.CV_8UC1);
+ assertFalse(gray.empty());
- public void testPutIntIntIntArray() {
- fail("Not yet implemented");
- }
+ Mat rgb = new Mat(1, 1, CvType.CV_8UC3);
+ assertFalse(rgb.empty());
+ }
- public void testPutIntIntShortArray() {
- fail("Not yet implemented");
- }
+ public void testMatIntIntCvTypeScalar() {
+ dst = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(
+ 127));
+ assertFalse(dst.empty());
+ assertMatEqual(dst, gray127);
- public void testRow() {
- Mat row = gray0.row(0);
- assertEquals(1, row.rows());
- assertEquals(gray0.cols(), row.cols());
- }
+ dst = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4,
+ Scalar.all(128));
+ assertFalse(dst.empty());
+ assertMatEqual(dst, rgba128);
+ }
- public void testRowRange() {
- Mat rows = gray0.rowRange(0, gray0.rows()/2);
- assertEquals(gray0.rows()/2, rows.rows());
- assertEquals(gray0.cols(), rows.cols());
- }
+ public void testMatIntIntInt() {
+ Mat gray = new Mat(1, 1, CvType.CV_8U);
+ assertFalse(gray.empty());
- public void testRows() {
- assertEquals(matSize, gray0.rows());
- }
+ Mat rgb = new Mat(1, 1, CvType.CV_8U);
+ assertFalse(rgb.empty());
+ }
- public void testSetTo() {
- gray0.setTo(new Scalar(127));
- assertMatEqual(gray127, gray0);
- }
+ public void testMatIntIntIntScalar() {
+ Mat m1 = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U,
+ new Scalar(127));
+ assertFalse(m1.empty());
+ assertMatEqual(m1, gray127);
- public void testSubmat() {
- Mat submat = gray0.submat(0, gray0.rows()/2, 0, gray0.cols()/2);
- assertEquals(gray0.rows()/2, submat.rows());
- assertEquals(gray0.cols()/2, submat.cols());
- }
+ Mat m2 = new Mat(gray0_32f.rows(), gray0_32f.cols(), CvType.CV_32F,
+ new Scalar(0));
+ assertFalse(m2.empty());
+ assertMatEqual(m2, gray0_32f, EPS);
+ }
- public void testToString() {
- assertTrue(null != gray0.toString());
- }
+ public void testPutIntIntByteArray() {
+ fail("Not yet implemented");
+ }
- public void testTotal() {
- int nElements = gray0.rows() * gray0.cols();
- assertEquals(nElements, gray0.total());
- }
+ public void testPutIntIntDoubleArray() {
+ fail("Not yet implemented");
+ }
- public void testType() {
- assertEquals(CvType.CV_8UC1, gray0.type());
- assertEquals(CvType.CV_32FC1, gray0_32f.type());
- assertEquals(CvType.CV_8UC3, rgbLena.type());
- }
+ public void testPutIntIntFloatArray() {
+ fail("Not yet implemented");
+ }
- public void testWidth() {
- assertEquals(gray0.cols(), gray0.width());
- assertEquals(rgbLena.cols(), rgbLena.width());
- assertEquals(rgba128.cols(), rgba128.width());
- }
+ public void testPutIntIntIntArray() {
+ fail("Not yet implemented");
+ }
+
+ public void testPutIntIntShortArray() {
+ fail("Not yet implemented");
+ }
+
+ public void testRow() {
+ Mat row = gray0.row(0);
+ assertEquals(1, row.rows());
+ assertEquals(gray0.cols(), row.cols());
+ }
+
+ public void testRowRange() {
+ Mat rows = gray0.rowRange(0, gray0.rows() / 2);
+ assertEquals(gray0.rows() / 2, rows.rows());
+ assertEquals(gray0.cols(), rows.cols());
+ }
+
+ public void testRows() {
+ assertEquals(matSize, gray0.rows());
+ }
+
+ public void testSetTo() {
+ gray0.setTo(new Scalar(127));
+ assertMatEqual(gray127, gray0);
+ }
+
+ public void testSubmat() {
+ Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2);
+ assertEquals(gray0.rows() / 2, submat.rows());
+ assertEquals(gray0.cols() / 2, submat.cols());
+ }
+
+ public void testToString() {
+ assertTrue(null != gray0.toString());
+ }
+
+ public void testTotal() {
+ int nElements = gray0.rows() * gray0.cols();
+ assertEquals(nElements, gray0.total());
+ }
+
+ public void testType() {
+ assertEquals(CvType.CV_8UC1, gray0.type());
+ assertEquals(CvType.CV_32FC1, gray0_32f.type());
+ assertEquals(CvType.CV_8UC3, rgbLena.type());
+ }
+
+ public void testWidth() {
+ assertEquals(gray0.cols(), gray0.width());
+ assertEquals(rgbLena.cols(), rgbLena.width());
+ assertEquals(rgba128.cols(), rgba128.width());
+ }
}
diff --git a/modules/java/android_test/src/org/opencv/test/core/coreTest.java b/modules/java/android_test/src/org/opencv/test/core/coreTest.java
index c808cb32e..5dd3ed776 100644
--- a/modules/java/android_test/src/org/opencv/test/core/coreTest.java
+++ b/modules/java/android_test/src/org/opencv/test/core/coreTest.java
@@ -39,7 +39,7 @@ public class coreTest extends OpenCVTestCase {
public void testAddMatMatMatMatInt() {
Core.add(gray0, gray1, dst, gray1, CvType.CV_32F);
assertTrue(CvType.CV_32F == dst.depth());
- assertMatEqual(gray1_32f, dst);
+ assertMatEqual(gray1_32f, dst, EPS);
}
public void testAddWeightedMatDoubleMatDoubleDoubleMat() {
@@ -50,7 +50,7 @@ public class coreTest extends OpenCVTestCase {
public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() {
Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst, CvType.CV_32F);
assertTrue(CvType.CV_32F == dst.depth());
- assertMatEqual(gray255_32f, dst);
+ assertMatEqual(gray255_32f, dst, EPS);
}
public void testBitwise_andMatMatMat() {
@@ -101,8 +101,8 @@ public class coreTest extends OpenCVTestCase {
* TODO:
* CV_COVAR_NORMAL
*/);
- assertMatEqual(gray0_64f, covar);
- assertMatEqual(gray0_64f_1d, mean);
+ assertMatEqual(gray0_64f, covar, EPS);
+ assertMatEqual(gray0_64f_1d, mean, EPS);
}
public void testCalcCovarMatrixMatMatMatIntInt() {
@@ -113,8 +113,8 @@ public class coreTest extends OpenCVTestCase {
* TODO:
* CV_COVAR_NORMAL
*/, CvType.CV_32F);
- assertMatEqual(gray0_32f, covar);
- assertMatEqual(gray0_32f_1d, mean);
+ assertMatEqual(gray0_32f, covar, EPS);
+ assertMatEqual(gray0_32f_1d, mean, EPS);
}
public void testCartToPolarMatMatMatMat() {
@@ -130,8 +130,8 @@ public class coreTest extends OpenCVTestCase {
Mat dst_angle = new Mat();
Core.cartToPolar(x, y, dst, dst_angle);
- assertMatEqual(magnitude, dst);
- assertMatEqual(angle, dst_angle);
+ assertMatEqual(magnitude, dst, EPS);
+ assertMatEqual(angle, dst_angle, EPS);
}
public void testCartToPolarMatMatMatMatBoolean() {
@@ -148,8 +148,8 @@ public class coreTest extends OpenCVTestCase {
Mat dst_angle = new Mat();
Core.cartToPolar(x, y, dst, dst_angle, false);
- assertMatEqual(magnitude, dst);
- assertMatEqual(angle, dst_angle);
+ assertMatEqual(magnitude, dst, EPS);
+ assertMatEqual(angle, dst_angle, EPS);
}
public void testCheckRangeMat() {
@@ -278,21 +278,21 @@ public class coreTest extends OpenCVTestCase {
public void testCompleteSymmMat() {
Core.completeSymm(grayRnd_32f);
Core.transpose(grayRnd_32f, dst);
- assertMatEqual(grayRnd_32f, dst);
+ assertMatEqual(grayRnd_32f, dst, EPS);
}
public void testCompleteSymmMatBoolean() {
Core.completeSymm(grayRnd_32f, true);
Core.transpose(grayRnd_32f, dst);
- assertMatEqual(grayRnd_32f, dst);
+ assertMatEqual(grayRnd_32f, dst, EPS);
}
public void testConvertScaleAbsMatMat() {
Core.convertScaleAbs(gray0, dst);
- assertMatEqual(gray0, dst);
+ assertMatEqual(gray0, dst, EPS);
Core.convertScaleAbs(gray_16u_256, dst);
- assertMatEqual(gray255, dst);
+ assertMatEqual(gray255, dst, EPS);
}
public void testConvertScaleAbsMatMatDouble() {
@@ -322,7 +322,7 @@ public class coreTest extends OpenCVTestCase {
public void testDctMatMat() {
Core.dct(gray0_32f_1d, dst);
- assertMatEqual(gray0_32f_1d, dst);
+ assertMatEqual(gray0_32f_1d, dst, EPS);
Mat in = new Mat(1, 4, CvType.CV_32F);
in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682);
@@ -331,12 +331,12 @@ public class coreTest extends OpenCVTestCase {
truth.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477);
Core.dct(in, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testDctMatMatInt() {
Core.dct(gray0_32f_1d, dst);
- assertMatEqual(gray0_32f_1d, dst);
+ assertMatEqual(gray0_32f_1d, dst, EPS);
Mat in = new Mat(1, 8, CvType.CV_32F);
in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382,
@@ -347,7 +347,7 @@ public class coreTest extends OpenCVTestCase {
-0.32499927, -0.99302113, 0.55979407, -0.6251272);
Core.dct(in, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testDeterminant() {
@@ -368,7 +368,7 @@ public class coreTest extends OpenCVTestCase {
truth = new Mat(1, 4, CvType.CV_32F);
truth.put(0, 0, 0, 0, 0, 0);
Core.dft(src, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testDftMatMatInt() {
@@ -378,11 +378,11 @@ public class coreTest extends OpenCVTestCase {
src.put(0, 0, 1, 2, 3, 4);
truth.put(0, 0, 10, -2, 2, -2);
Core.dft(src, dst, Core.DFT_REAL_OUTPUT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
Core.dft(src, dst, Core.DFT_INVERSE);
truth.put(0, 0, 9, -9, 1, 3);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testDftMatMatIntInt() {
@@ -392,7 +392,7 @@ public class coreTest extends OpenCVTestCase {
truth = new Mat(1, 4, CvType.CV_32F);
truth.put(0, 0, 10, -2, 2, -2);
Core.dft(src, dst, Core.DFT_REAL_OUTPUT, 1);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testDivideDoubleMatMat() {
@@ -460,7 +460,7 @@ public class coreTest extends OpenCVTestCase {
Mat destination = new Mat(matSize, matSize, CvType.CV_32F);
destination.setTo(new Scalar(0.0));
Core.exp(gray0_32f, destination);
- assertMatEqual(gray1_32f, destination);
+ assertMatEqual(gray1_32f, destination, EPS);
}
public void testExtractChannel() {
@@ -518,7 +518,7 @@ public class coreTest extends OpenCVTestCase {
des_f0.put(1, 0, 1.0);
des_f0.put(1, 1, 2.0);
Core.flip(src, dst, 0);
- assertMatEqual(des_f0, dst);
+ assertMatEqual(des_f0, dst, EPS);
Mat des_f1 = new Mat(2, 2, CvType.CV_32F);
des_f1.put(0, 0, 2.0);
@@ -526,7 +526,7 @@ public class coreTest extends OpenCVTestCase {
des_f1.put(1, 0, 4.0);
des_f1.put(1, 1, 3.0);
Core.flip(src, dst, 1);
- assertMatEqual(des_f1, dst);
+ assertMatEqual(des_f1, dst, EPS);
}
public void testGemmMatMatDoubleMatDoubleMat() {
@@ -548,7 +548,7 @@ public class coreTest extends OpenCVTestCase {
desired.put(1, 0, 1.001, 0.001);
Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst);
- assertMatEqual(desired, dst);
+ assertMatEqual(desired, dst, EPS);
}
public void testGemmMatMatDoubleMatDoubleMatInt() {
@@ -570,7 +570,7 @@ public class coreTest extends OpenCVTestCase {
desired.put(1, 0, 0.001, 0.001);
Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst, Core.GEMM_1_T);
- assertMatEqual(desired, dst);
+ assertMatEqual(desired, dst, EPS);
}
public void testGetCPUTickCount() {
@@ -619,7 +619,7 @@ public class coreTest extends OpenCVTestCase {
-0.86502546, 0.028082132, -0.7673766, 0.10917115);
Core.idct(in, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testIdctMatMatInt() {
@@ -631,7 +631,7 @@ public class coreTest extends OpenCVTestCase {
-0.86502546, 0.028082132, -0.7673766, 0.10917115);
Core.idct(in, dst, Core.DCT_ROWS);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testIdftMatMat() {
@@ -642,7 +642,7 @@ public class coreTest extends OpenCVTestCase {
truth.put(0, 0, 9, -9, 1, 3);
Core.idft(in, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testIdftMatMatInt() {
@@ -652,7 +652,7 @@ public class coreTest extends OpenCVTestCase {
truth = new Mat(1, 4, CvType.CV_32F);
truth.put(0, 0, 9, -9, 1, 3);
Core.idft(in, dst, Core.DFT_REAL_OUTPUT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testIdftMatMatIntInt() {
@@ -662,7 +662,7 @@ public class coreTest extends OpenCVTestCase {
truth = new Mat(1, 4, CvType.CV_32F);
truth.put(0, 0, 9, -9, 1, 3);
Core.idft(in, dst, Core.DFT_REAL_OUTPUT, 1);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testInRange() {
@@ -692,7 +692,7 @@ public class coreTest extends OpenCVTestCase {
truth.put(1, 1, 1.0);
Core.invert(src, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
// TODO: needs epsilon comparison
// Mat m = grayRnd_32f.clone();
@@ -707,7 +707,7 @@ public class coreTest extends OpenCVTestCase {
truth = Mat.eye(3, 3, CvType.CV_32FC1);
Core.invert(src, dst, Core.DECOMP_CHOLESKY);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
Core.invert(src, dst, Core.DECOMP_LU);
double det = Core.determinant(src);
@@ -761,7 +761,7 @@ public class coreTest extends OpenCVTestCase {
desired.put(0, 0, 0, 2.3025851, 4.6051702, 6.9077554);
Core.log(in, dst);
- assertMatEqual(desired, dst);
+ assertMatEqual(desired, dst, EPS);
}
public void testLUTMatMatMat() {
@@ -793,10 +793,10 @@ public class coreTest extends OpenCVTestCase {
out.put(0, 0, 5.0, 13.0, 41.0, 10.0);
Core.magnitude(x, y, dst);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
Core.magnitude(gray0_32f, gray255_32f, dst);
- assertMatEqual(gray255_32f, dst);
+ assertMatEqual(gray255_32f, dst, EPS);
}
public void testMahalanobis() {
@@ -830,7 +830,7 @@ public class coreTest extends OpenCVTestCase {
y.put(0, 0, 4.0);
dst.put(0, 0, 23.0);
Core.max(x, y, dst);
- assertMatEqual(dst, dst);
+ assertMatEqual(dst, dst, EPS);
}
public void testMeanMat() {
@@ -871,7 +871,7 @@ public class coreTest extends OpenCVTestCase {
Core.meanStdDev(grayRnd, mean, stddev, mask);
Mat desiredMean = new Mat(1, 1, CvType.CV_64F, new Scalar(33));
- assertMatEqual(desiredMean, mean);
+ assertMatEqual(desiredMean, mean, EPS);
assertEquals(0, Core.countNonZero(stddev));
Core.meanStdDev(grayRnd, mean, stddev, gray1);
@@ -924,7 +924,7 @@ public class coreTest extends OpenCVTestCase {
src2.put(0, 0, 1.0, 2.0, 3.0, 4.0);
out.put(0, 0, 1, -5, 12, 16);
Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testMulSpectrumsMatMatMatIntBoolean() {
@@ -935,7 +935,7 @@ public class coreTest extends OpenCVTestCase {
src2.put(0, 0, 1.0, 2.0, 3.0, 4.0);
out.put(0, 0, 1, 13, 0, 16);
Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS, true);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testMultiplyMatMatMat() {
@@ -956,24 +956,24 @@ public class coreTest extends OpenCVTestCase {
public void testMulTransposedMatMatBoolean() {
Core.mulTransposed(grayE_32f, dst, true);
- assertMatEqual(grayE_32f, dst);
+ assertMatEqual(grayE_32f, dst, EPS);
}
public void testMulTransposedMatMatBooleanMat() {
Core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f);
- assertMatEqual(gray0_32f, dst);
+ assertMatEqual(gray0_32f, dst, EPS);
Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F);
grayDelta.setTo(new Scalar(0.0));
Core.mulTransposed(grayE_32f, dst, true, grayDelta);
- assertMatEqual(grayE_32f, dst);
+ assertMatEqual(grayE_32f, dst, EPS);
}
public void testMulTransposedMatMatBooleanMatDouble() {
Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F);
grayDelta.setTo(new Scalar(0.0));
Core.mulTransposed(grayE_32f, dst, true, grayDelta, 1);
- assertMatEqual(grayE_32f, dst);
+ assertMatEqual(grayE_32f, dst, EPS);
}
public void testMulTransposedMatMatBooleanMatDoubleInt() {
@@ -989,7 +989,7 @@ public class coreTest extends OpenCVTestCase {
res.put(2, 0, 3, 3, 3);
Core.mulTransposed(a, dst, true, grayDelta, 1.0, 1);
- assertMatEqual(res, dst);
+ assertMatEqual(res, dst, EPS);
}
public void testNormalizeMatMat() {
@@ -1013,7 +1013,7 @@ public class coreTest extends OpenCVTestCase {
src.put(0, 0, 1.0, 2.0, 3.0, 4.0);
out.put(0, 0, 0.25, 0.5, 0.75, 1);
Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testNormalizeMatMatDoubleDoubleIntInt() {
@@ -1024,7 +1024,7 @@ public class coreTest extends OpenCVTestCase {
out.put(0, 0, 0.25, 0.5, 0.75, 1);
Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testNormalizeMatMatDoubleDoubleIntIntMat() {
@@ -1036,7 +1036,7 @@ public class coreTest extends OpenCVTestCase {
out.put(0, 0, 0.25, 0.5, 0.75, 1);
Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1, mask);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testNormMat() {
@@ -1124,7 +1124,7 @@ public class coreTest extends OpenCVTestCase {
res.put(0, 0, 1.1071469, 0.98280007, 0.78539175, 1.3258134);
Core.phase(x, y, dst);
- assertMatEqual(res, dst);
+ assertMatEqual(res, dst, EPS);
}
public void testPhaseMatMatMatBoolean() {
@@ -1160,7 +1160,7 @@ public class coreTest extends OpenCVTestCase {
// TODO: needs epsilon comparison
Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate);
- assertMatEqual(x, xCoordinate);
+ assertMatEqual(x, xCoordinate, EPS);
}
public void testPolarToCartMatMatMatMatBoolean() {
@@ -1279,7 +1279,7 @@ public class coreTest extends OpenCVTestCase {
out.put(0, 0, 1, 0);
Core.reduce(src, dst, 0, 2);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testReduceMatMatIntIntInt() {
@@ -1291,7 +1291,7 @@ public class coreTest extends OpenCVTestCase {
out.put(0, 0, 1, 0);
Core.reduce(src, dst, 0, 2, -1);
- assertMatEqual(out, dst);
+ assertMatEqual(out, dst, EPS);
}
public void testRepeat() {
@@ -1304,9 +1304,9 @@ public class coreTest extends OpenCVTestCase {
des2.put(0, 0, 1, 2, 3, 1, 2, 3);
Core.repeat(src, 1, 1, dst);
- assertMatEqual(des1, dst);
+ assertMatEqual(des1, dst, EPS);
Core.repeat(src, 1, 2, dst);
- assertMatEqual(des2, dst);
+ assertMatEqual(des2, dst, EPS);
}
public void testScaleAdd() {
@@ -1316,13 +1316,13 @@ public class coreTest extends OpenCVTestCase {
public void testSetIdentityMat() {
Core.setIdentity(gray0_32f);
- assertMatEqual(grayE_32f, gray0_32f);
+ assertMatEqual(grayE_32f, gray0_32f, EPS);
}
public void testSetIdentityMatScalar() {
Core.gemm(grayE_32f, grayE_32f, 5.0, new Mat(), 0.0, dst);
Core.setIdentity(gray0_32f, new Scalar(5));
- assertMatEqual(dst, gray0_32f);
+ assertMatEqual(dst, gray0_32f, EPS);
}
public void testSolveCubic() {
@@ -1331,7 +1331,7 @@ public class coreTest extends OpenCVTestCase {
coeffs.put(0, 0, 1, 6, 11, 6);
roots.put(0, 0, -3, -1, -2);
Core.solveCubic(coeffs, dst);
- assertMatEqual(roots, dst);
+ assertMatEqual(roots, dst, EPS);
}
public void testSolveMatMatMat() {
@@ -1346,7 +1346,7 @@ public class coreTest extends OpenCVTestCase {
res.put(0, 0, -12, 2, 10);
Core.solve(a, b, dst);
- assertMatEqual(res, dst);
+ assertMatEqual(res, dst, EPS);
}
public void testSolveMatMatMatInt() {
@@ -1362,7 +1362,7 @@ public class coreTest extends OpenCVTestCase {
res.put(0, 0, -12, 2, 10);
Core.solve(a, b, dst, 3);
- assertMatEqual(res, dst);
+ assertMatEqual(res, dst, EPS);
}
public void testSolvePolyMatMat() {
@@ -1375,7 +1375,7 @@ public class coreTest extends OpenCVTestCase {
truth.put(0, 0, 1, 0, 2, 0, 3, 0);
Core.solvePoly(coeffs, roots);
- assertMatEqual(truth, roots);
+ assertMatEqual(truth, roots, EPS);
}
public void testSolvePolyMatMatInt() {
@@ -1388,7 +1388,7 @@ public class coreTest extends OpenCVTestCase {
truth.put(0, 0, 1, 0, -1, 2, -2, 12);
Core.solvePoly(coeffs, roots, 1);
- assertMatEqual(truth, roots);
+ assertMatEqual(truth, roots, EPS);
}
public void testSort() {
@@ -1427,7 +1427,7 @@ public class coreTest extends OpenCVTestCase {
public void testSqrt() {
Core.sqrt(gray9_32f, dst);
- assertMatEqual(gray3_32f, dst);
+ assertMatEqual(gray3_32f, dst, EPS);
Mat rgba144 = new Mat(matSize, matSize, CvType.CV_32FC4);
Mat rgba12 = new Mat(matSize, matSize, CvType.CV_32FC4);
@@ -1435,7 +1435,7 @@ public class coreTest extends OpenCVTestCase {
rgba12.setTo(Scalar.all(12));
Core.sqrt(rgba144, dst);
- assertMatEqual(rgba12, dst);
+ assertMatEqual(rgba12, dst, EPS);
}
public void testSubtractMatMatMat() {
@@ -1456,7 +1456,7 @@ public class coreTest extends OpenCVTestCase {
public void testSubtractMatMatMatMatInt() {
Core.subtract(gray3, gray2, dst, gray1, CvType.CV_32F);
assertTrue(CvType.CV_32F == dst.depth());
- assertMatEqual(gray1_32f, dst);
+ assertMatEqual(gray1_32f, dst, EPS);
}
public void testSumElems() {
@@ -1485,7 +1485,7 @@ public class coreTest extends OpenCVTestCase {
Core.transform(src, dst, m);
truth = new Mat(2, 2, CvType.CV_32FC2, new Scalar(55, 1));
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testTranspose() {
diff --git a/modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java b/modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java
index 35a264ec0..5468f0e6d 100644
--- a/modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java
+++ b/modules/java/android_test/src/org/opencv/test/imgproc/imgprocTest.java
@@ -43,18 +43,18 @@ public class imgprocTest extends OpenCVTestCase {
public void testAccumulateMatMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
dst = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
Imgproc.accumulate(gray1_32f, dst);
- assertMatEqual(gray1_32f, dst);
+ assertMatEqual(gray1_32f, dst, EPS);
}
public void testAccumulateMatMatMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(2));
Imgproc.accumulate(gray_64f_2, dst64F, mask); // TODO: use better mask
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAccumulateProductMatMatMat() {
@@ -71,7 +71,7 @@ public class imgprocTest extends OpenCVTestCase {
Mat dstImage = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(
0));
Imgproc.accumulateProduct(src1, src2, dstImage);
- assertMatEqual(truth, dstImage);
+ assertMatEqual(truth, dstImage, EPS);
}
public void testAccumulateProductMatMatMatMat() {
@@ -88,34 +88,34 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 0, 2);
Imgproc.accumulateProduct(src1, src2, dst64F, mask);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAccumulateSquareMatMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateSquare(gray_64f_2, dst64F);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAccumulateSquareMatMatMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateSquare(gray_64f_2, dst64F, mask);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAccumulateWeightedMatMatDouble() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(4));
Imgproc.accumulateWeighted(gray_64f_2, dst64F, 2.0);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAccumulateWeightedMatMatDoubleMat() {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_64F, new Scalar(8));
Imgproc.accumulateWeighted(gray_64f_2, dst64F, 4.0, mask);
- assertMatEqual(truth, dst64F);
+ assertMatEqual(truth, dst64F, EPS);
}
public void testAdaptiveThreshold() {
@@ -132,7 +132,7 @@ public class imgprocTest extends OpenCVTestCase {
approxCurve.put(0, 0, 1.0, 3.0, 3.0, 5.0, 5.0, 3.0);
Imgproc.approxPolyDP(curve, dst, EPS, true);
- assertMatEqual(approxCurve, dst);
+ assertMatEqual(approxCurve, dst, EPS);
}
public void testArcLength() {
@@ -255,7 +255,7 @@ public class imgprocTest extends OpenCVTestCase {
Mat hist = new Mat();
Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
- assertMatEqual(truth, hist);
+ assertMatEqual(truth, hist, EPS);
}
public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloat2d() {
@@ -283,7 +283,7 @@ public class imgprocTest extends OpenCVTestCase {
Mat hist = new Mat();
Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges);
- assertMatEqual(truth, hist);
+ assertMatEqual(truth, hist, EPS);
}
public void testCalcHistListOfMatListOfIntegerMatMatListOfIntegerListOfFloatBoolean() {
@@ -311,7 +311,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(9, 5, 100.0);
Imgproc.calcHist(images, channels, new Mat(), hist, histSize, ranges,
true);
- assertMatEqual(truth, hist);
+ assertMatEqual(truth, hist, EPS);
}
public void testCannyMatMatDoubleDouble() {
@@ -380,7 +380,7 @@ public class imgprocTest extends OpenCVTestCase {
expHull.put(0, 0, 4, 0, 3, 2, 0, 2, 2, 0);
Imgproc.convexHull(points, dst);
- assertMatEqual(expHull, dst);
+ assertMatEqual(expHull, dst, EPS);
}
public void testConvexHullMatMatBoolean() {
@@ -392,7 +392,7 @@ public class imgprocTest extends OpenCVTestCase {
expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0);
Imgproc.convexHull(points, dst, true);
- assertMatEqual(expHull, dst);
+ assertMatEqual(expHull, dst, EPS);
}
public void testConvexHullMatMatBooleanBoolean() {
@@ -404,7 +404,7 @@ public class imgprocTest extends OpenCVTestCase {
expHull.put(0, 0, 0, 2, 3, 2, 4, 0, 2, 0);
Imgproc.convexHull(points, dst, true, true);
- assertMatEqual(expHull, dst);
+ assertMatEqual(expHull, dst, EPS);
}
public void testCopyMakeBorderMatMatIntIntIntIntInt() {
@@ -414,7 +414,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.copyMakeBorder(src, dst, border, border, border, border,
Imgproc.BORDER_REPLICATE);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCopyMakeBorderMatMatIntIntIntIntIntScalar() {
@@ -426,7 +426,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.copyMakeBorder(src, dst, border, border, border, border,
Imgproc.BORDER_REPLICATE, value);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerEigenValsAndVecsMatMatIntInt() {
@@ -440,7 +440,7 @@ public class imgprocTest extends OpenCVTestCase {
// TODO: eigen vals and vectors returned = 0 for most src matrices
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC(6), new Scalar(0));
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerEigenValsAndVecsMatMatIntIntInt() {
@@ -453,7 +453,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.cornerEigenValsAndVecs(src, dst, blockSize, ksize,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerHarrisMatMatIntIntDouble() {
@@ -462,7 +462,7 @@ public class imgprocTest extends OpenCVTestCase {
int ksize = 7;
double k = 0.1;
Imgproc.cornerHarris(gray128, dst, blockSize, ksize, k);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerHarrisMatMatIntIntDoubleInt() {
@@ -472,7 +472,7 @@ public class imgprocTest extends OpenCVTestCase {
double k = 0.1;
Imgproc.cornerHarris(gray255, dst, blockSize, ksize, k,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerMinEigenValMatMatInt() {
@@ -484,11 +484,11 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32FC1, new Scalar(0));
Imgproc.cornerMinEigenVal(src, dst, blockSize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
Mat truth1 = new Mat(matSize, matSize, CvType.CV_32FC1, new Scalar(0));
Imgproc.cornerMinEigenVal(gray255, dst, blockSize);
- assertMatEqual(truth1, dst);
+ assertMatEqual(truth1, dst, EPS);
}
public void testCornerMinEigenValMatMatIntInt() {
@@ -503,7 +503,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0.055555549, 0.027777772, 0.055555549);
Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerMinEigenValMatMatIntIntInt() {
@@ -519,7 +519,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.cornerMinEigenVal(src, dst, blockSize, ksize,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testCornerSubPix() {
@@ -583,7 +583,7 @@ public class imgprocTest extends OpenCVTestCase {
Mat labels = new Mat();
Imgproc.distanceTransform(gray128, dst, labels, Imgproc.CV_DIST_L2, 3);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
assertMatEqual(dstLables, labels);
}
@@ -691,7 +691,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(3, 0, 0, 0, 1, 2);
Imgproc.filter2D(src, dst, -1, kernel);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testFilter2DMatMatIntMatPoint() {
@@ -770,7 +770,7 @@ public class imgprocTest extends OpenCVTestCase {
linePoints.put(0, 0, 0.53196341, 0.84676737, 2.496531, 3.7467217);
Imgproc.fitLine(points, dst, Imgproc.CV_DIST_L12, 0, 0.01, 0.01);
- assertMatEqual(linePoints, dst);
+ assertMatEqual(linePoints, dst, EPS);
}
public void testFloodFillMatMatPointScalar() {
@@ -872,8 +872,8 @@ public class imgprocTest extends OpenCVTestCase {
expKy.put(0, 0, 1, -2, 1);
Imgproc.getDerivKernels(kx, ky, 2, 2, 3);
- assertMatEqual(expKx, kx);
- assertMatEqual(expKy, ky);
+ assertMatEqual(expKx, kx, EPS);
+ assertMatEqual(expKy, ky, EPS);
}
public void testGetDerivKernelsMatMatIntIntIntBoolean() {
@@ -892,8 +892,8 @@ public class imgprocTest extends OpenCVTestCase {
expKy.put(0, 0, 1, -2, 1);
Imgproc.getDerivKernels(kx, ky, 2, 2, 3, true);
- assertMatEqual(expKx, kx);
- assertMatEqual(expKy, ky);
+ assertMatEqual(expKx, kx, EPS);
+ assertMatEqual(expKy, ky, EPS);
}
public void testGetDerivKernelsMatMatIntIntIntBooleanInt() {
@@ -912,15 +912,15 @@ public class imgprocTest extends OpenCVTestCase {
expKy.put(0, 0, 1, -2, 1);
Imgproc.getDerivKernels(kx, ky, 2, 2, 3, true, CvType.CV_32F);
- assertMatEqual(expKx, kx);
- assertMatEqual(expKy, ky);
+ assertMatEqual(expKx, kx, EPS);
+ assertMatEqual(expKy, ky, EPS);
}
public void testGetGaussianKernelIntDouble() {
truth = new Mat(1, 1, CvType.CV_64FC1, new Scalar(1.0));
dst = Imgproc.getGaussianKernel(1, 0.5);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testGetGaussianKernelIntDoubleInt() {
@@ -928,7 +928,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(0, 0, 0.23899426, 0.52201146, 0.23899426);
dst = Imgproc.getGaussianKernel(3, 0.8, CvType.CV_32F);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testGetRectSubPixMatSizePointMat() {
@@ -947,7 +947,7 @@ public class imgprocTest extends OpenCVTestCase {
Point center = new Point(src.cols() / 2, src.rows() / 2);
Imgproc.getRectSubPix(src, patchSize, center, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testGetRotationMatrix2D() {
@@ -956,7 +956,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 0, 1, 0);
Point center = new Point(0, 0);
dst = Imgproc.getRotationMatrix2D(center, 0.0, 1.0);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testGetStructuringElementIntSize() {
@@ -1135,8 +1135,8 @@ public class imgprocTest extends OpenCVTestCase {
expSqsum.put(3, 0, 0, 27, 54, 81);
Imgproc.integral2(src, sum, sqsum);
- assertMatEqual(expSum, sum);
- assertMatEqual(expSqsum, sqsum);
+ assertMatEqual(expSum, sum, EPS);
+ assertMatEqual(expSqsum, sqsum, EPS);
}
public void testIntegral2MatMatMatInt() {
@@ -1157,8 +1157,8 @@ public class imgprocTest extends OpenCVTestCase {
expSqsum.put(3, 0, 0, 27, 54, 81);
Imgproc.integral2(src, sum, sqsum, CvType.CV_64F);
- assertMatEqual(expSum, sum);
- assertMatEqual(expSqsum, sqsum);
+ assertMatEqual(expSum, sum, EPS);
+ assertMatEqual(expSqsum, sqsum, EPS);
}
public void testIntegral3MatMatMatMat() {
@@ -1180,9 +1180,9 @@ public class imgprocTest extends OpenCVTestCase {
expTilted.put(1, 0, 0, 1);
Imgproc.integral3(src, sum, sqsum, tilted);
- assertMatEqual(expSum, sum);
- assertMatEqual(expSqsum, sqsum);
- assertMatEqual(expTilted, tilted);
+ assertMatEqual(expSum, sum, EPS);
+ assertMatEqual(expSqsum, sqsum, EPS);
+ assertMatEqual(expTilted, tilted, EPS);
}
@@ -1205,9 +1205,9 @@ public class imgprocTest extends OpenCVTestCase {
expTilted.put(1, 0, 0, 1);
Imgproc.integral3(src, sum, sqsum, tilted, CvType.CV_64F);
- assertMatEqual(expSum, sum);
- assertMatEqual(expSqsum, sqsum);
- assertMatEqual(expTilted, tilted);
+ assertMatEqual(expSum, sum, EPS);
+ assertMatEqual(expSqsum, sqsum, EPS);
+ assertMatEqual(expTilted, tilted, EPS);
}
public void testIntegralMatMat() {
@@ -1219,7 +1219,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0, 4, 8);
Imgproc.integral(src, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
@@ -1232,7 +1232,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0, 4, 8);
Imgproc.integral(src, dst, CvType.CV_64F);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testInvertAffineTransform() {
@@ -1240,7 +1240,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(2, 3, CvType.CV_64F, new Scalar(0));
Imgproc.invertAffineTransform(src, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testIsContourConvex() {
@@ -1263,7 +1263,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(0.0));
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testLaplacianMatMatIntIntDouble() {
@@ -1275,7 +1275,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 8, -8);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testLaplacianMatMatIntIntDoubleDouble() {
@@ -1287,7 +1287,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 8.0009995, -7.9990001);
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, EPS);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testLaplacianMatMatIntIntDoubleDoubleInt() {
@@ -1296,7 +1296,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.Laplacian(src, dst, CvType.CV_32F, 1, 2.0, EPS,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testMatchShapes() {
@@ -1322,11 +1322,11 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(1, 1, CvType.CV_32F, new Scalar(70));
Imgproc.matchTemplate(image, templ, dst, Imgproc.TM_CCORR);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
truth = new Mat(1, 1, CvType.CV_32F, new Scalar(0));
Imgproc.matchTemplate(gray255, gray0, dst, Imgproc.TM_CCORR);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testMedianBlur() {
@@ -1451,7 +1451,7 @@ public class imgprocTest extends OpenCVTestCase {
int ksize = 3;
Imgproc.preCornerDetect(src, dst, ksize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testPreCornerDetectMatMatIntInt() {
@@ -1460,7 +1460,7 @@ public class imgprocTest extends OpenCVTestCase {
int ksize = 3;
Imgproc.preCornerDetect(src, dst, ksize, Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testPyrDownMatMat() {
@@ -1475,7 +1475,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F);
truth.put(0, 0, 2.78125, 4.609375);
truth.put(1, 0, 8.546875, 8.8515625);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testPyrDownMatMatSize() {
@@ -1492,7 +1492,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 8.546875, 8.8515625);
Imgproc.pyrDown(src, dst, dstSize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testPyrMeanShiftFilteringMatMatDoubleDouble() {
@@ -1522,7 +1522,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(3, 0, 2.25, 2, 1.625, 1.5);
Imgproc.pyrUp(src, dst);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testPyrUpMatMatSize() {
@@ -1538,7 +1538,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(3, 0, 2.25, 2, 1.625, 1.5);
Imgproc.pyrUp(src, dst, dstSize);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testRemapMatMatMatMatInt() {
@@ -1552,7 +1552,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(1, 3, CvType.CV_32F, new Scalar(0));
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testRemapMatMatMatMatIntInt() {
@@ -1567,7 +1567,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testRemapMatMatMatMatIntIntScalar() {
@@ -1584,7 +1584,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.remap(src, dst, map1, map2, Imgproc.INTER_LINEAR,
Imgproc.BORDER_REFLECT, sc);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testResizeMatMatSize() {
@@ -1625,7 +1625,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0));
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testScharrMatMatIntIntIntDouble() {
@@ -1633,7 +1633,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0));
Imgproc.Scharr(src, dst, CvType.CV_32F, 0, 1, 1.5);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testScharrMatMatIntIntIntDoubleDouble() {
@@ -1641,7 +1641,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(0.001));
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.001);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testScharrMatMatIntIntIntDoubleDoubleInt() {
@@ -1654,7 +1654,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.Scharr(src, dst, CvType.CV_32F, 1, 0, 1.5, 0.0,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testSepFilter2DMatMatIntMatMat() {
@@ -1667,7 +1667,7 @@ public class imgprocTest extends OpenCVTestCase {
kernelY.put(0, 0, 9.0, 4.0, 2.0);
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testSepFilter2DMatMatIntMatMatPoint() {
@@ -1682,7 +1682,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY,
anchorPoint);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testSepFilter2DMatMatIntMatMatPointDouble() {
@@ -1698,7 +1698,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(imgprocSz, imgprocSz, CvType.CV_32F, new Scalar(36.001));
Imgproc.sepFilter2D(src, dst, CvType.CV_32F, kernelX, kernelY,
anchorPoint, EPS);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testSepFilter2DMatMatIntMatMatPointDoubleInt() {
@@ -1711,7 +1711,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(10, 10, CvType.CV_32F, new Scalar(0.001));
Imgproc.sepFilter2D(gray0, dst, CvType.CV_32F, kernelX, kernelY,
anchorPoint, EPS, Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testSobelMatMatIntIntInt() {
@@ -1736,8 +1736,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0, -24, 0);
Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0);
- assertMatEqual(truth, dst);
-
+ assertMatEqual(truth, dst, EPS);
}
public void testSobelMatMatIntIntIntIntDoubleDouble() {
@@ -1758,7 +1757,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.Sobel(src, dst, CvType.CV_32F, 1, 0, 3, 2.0, 0.0,
Imgproc.BORDER_REPLICATE);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testThreshold() {
@@ -1790,7 +1789,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0, 3, 0);
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testUndistortMatMatMatMatMat() {
@@ -1809,7 +1808,7 @@ public class imgprocTest extends OpenCVTestCase {
truth = new Mat(3, 3, CvType.CV_32F, new Scalar(3));
Imgproc.undistort(src, dst, cameraMatrix, distCoeffs, newCameraMatrix);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpAffineMatMatMatSize() {
@@ -1830,7 +1829,7 @@ public class imgprocTest extends OpenCVTestCase {
M.put(1, 0, 0, 1, 1);
Imgproc.warpAffine(src, dst, M, size);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpAffineMatMatMatSizeInt() {
@@ -1850,7 +1849,7 @@ public class imgprocTest extends OpenCVTestCase {
M.put(1, 0, 0, 0, 1);
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpAffineMatMatMatSizeIntInt() {
@@ -1869,7 +1868,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP,
Imgproc.BORDER_TRANSPARENT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpAffineMatMatMatSizeIntIntScalar() {
@@ -1891,7 +1890,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.warpAffine(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP,
Imgproc.BORDER_CONSTANT, sc);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpPerspectiveMatMatMatSize() {
@@ -1912,7 +1911,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(2, 0, 0, 0, 4);
Imgproc.warpPerspective(src, dst, M, size);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpPerspectiveMatMatMatSizeInt() {
@@ -1932,8 +1931,7 @@ public class imgprocTest extends OpenCVTestCase {
truth.put(1, 0, 6, 4);
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP);
- assertMatEqual(truth, dst);
-
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpPerspectiveMatMatMatSizeIntInt() {
@@ -1954,7 +1952,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP,
Imgproc.BORDER_REFLECT);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWarpPerspectiveMatMatMatSizeIntIntScalar() {
@@ -1973,7 +1971,7 @@ public class imgprocTest extends OpenCVTestCase {
Imgproc.warpPerspective(src, dst, M, dsize, Imgproc.WARP_INVERSE_MAP,
Imgproc.BORDER_REFLECT, sc);
- assertMatEqual(truth, dst);
+ assertMatEqual(truth, dst, EPS);
}
public void testWatershed() {
diff --git a/modules/java/src/cpp/Mat.cpp b/modules/java/src/cpp/Mat.cpp
index ae580f84b..5829d7a8a 100644
--- a/modules/java/src/cpp/Mat.cpp
+++ b/modules/java/src/cpp/Mat.cpp
@@ -13,42 +13,42 @@ extern "C" {
#endif
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nType
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->type( );
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nRows
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->rows;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nCols
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->cols;
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nData
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return (jlong) me->data;
}
JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsEmpty
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->empty();
}
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nSize
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
try {
#ifdef DEBUG
@@ -58,8 +58,8 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nSize
cv::Size _retval_ = me->size();
jdoubleArray _da_retval_ = env->NewDoubleArray(2);
- jdouble _tmp_retval_[4] = {_retval_.width, _retval_.height};
- env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_);
+ jdouble _tmp_retval_[4] = {_retval_.width, _retval_.height};
+ env->SetDoubleArrayRegion(_da_retval_, 0, 2, _tmp_retval_);
return _da_retval_;
} catch(cv::Exception e) {
#ifdef DEBUG
@@ -80,32 +80,32 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nSize
}
JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsCont
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->isContinuous();
}
JNIEXPORT jboolean JNICALL Java_org_opencv_core_Mat_nIsSubmat
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return me->isSubmatrix();
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nSubmat
- (JNIEnv* env, jclass cls, jlong self, jint r1, jint r2, jint c1, jint c2)
+ (JNIEnv* env, jclass cls, jlong self, jint r1, jint r2, jint c1, jint c2)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return (jlong) new cv::Mat(*me, cv::Range(r1, r2>0 ? r2 : me->rows), cv::Range(c1, c2>0 ? c2 : me->cols));
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nClone
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
cv::Mat* it = new cv::Mat();
- me->copyTo(*it);
+ me->copyTo(*it);
return (jlong) it;
}
@@ -113,47 +113,47 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nClone
#define PUT_ITEM(T, R, C) { T*dst = (T*)me->ptr(R, C); for(int ch=0; chchannels() && count>0; count--,ch++,src++,dst++) *dst = cv::saturate_cast(*src); }
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(!me || !me->data) return 0; // no native object behind
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+ cv::Mat* me = (cv::Mat*) self;
+ if(!me || !me->data) return 0; // no native object behind
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
- int rest = ((me->rows - row) * me->cols - col) * me->channels();
- if(count>rest) count = rest;
- int res = count;
- double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);
- double* src = values;
- int r, c;
- for(c=col; ccols && count>0; c++)
- {
- switch(me->depth()) {
- case CV_8U: PUT_ITEM(uchar, row, c); break;
- case CV_8S: PUT_ITEM(schar, row, c); break;
- case CV_16U: PUT_ITEM(ushort, row, c); break;
- case CV_16S: PUT_ITEM(short, row, c); break;
- case CV_32S: PUT_ITEM(int, row, c); break;
- case CV_32F: PUT_ITEM(float, row, c); break;
- case CV_64F: PUT_ITEM(double, row, c); break;
- }
- }
+ int rest = ((me->rows - row) * me->cols - col) * me->channels();
+ if(count>rest) count = rest;
+ int res = count;
+ double* values = (double*)env->GetPrimitiveArrayCritical(vals, 0);
+ double* src = values;
+ int r, c;
+ for(c=col; ccols && count>0; c++)
+ {
+ switch(me->depth()) {
+ case CV_8U: PUT_ITEM(uchar, row, c); break;
+ case CV_8S: PUT_ITEM(schar, row, c); break;
+ case CV_16U: PUT_ITEM(ushort, row, c); break;
+ case CV_16S: PUT_ITEM(short, row, c); break;
+ case CV_32S: PUT_ITEM(int, row, c); break;
+ case CV_32F: PUT_ITEM(float, row, c); break;
+ case CV_64F: PUT_ITEM(double, row, c); break;
+ }
+ }
- for(r=row+1; rrows && count>0; r++)
- for(c=0; ccols && count>0; c++)
- {
- switch(me->depth()) {
- case CV_8U: PUT_ITEM(uchar, r, c); break;
- case CV_8S: PUT_ITEM(schar, r, c); break;
- case CV_16U: PUT_ITEM(ushort, r, c); break;
- case CV_16S: PUT_ITEM(short, r, c); break;
- case CV_32S: PUT_ITEM(int, r, c); break;
- case CV_32F: PUT_ITEM(float, r, c); break;
- case CV_64F: PUT_ITEM(double, r, c); break;
- }
- }
+ for(r=row+1; rrows && count>0; r++)
+ for(c=0; ccols && count>0; c++)
+ {
+ switch(me->depth()) {
+ case CV_8U: PUT_ITEM(uchar, r, c); break;
+ case CV_8S: PUT_ITEM(schar, r, c); break;
+ case CV_16U: PUT_ITEM(ushort, r, c); break;
+ case CV_16S: PUT_ITEM(short, r, c); break;
+ case CV_32S: PUT_ITEM(int, r, c); break;
+ case CV_32F: PUT_ITEM(float, r, c); break;
+ case CV_64F: PUT_ITEM(double, r, c); break;
+ }
+ }
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
@@ -163,32 +163,32 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutD
template static int mat_put(cv::Mat* m, int row, int col, int count, char* buff)
{
- if(! m) return 0;
- if(! buff) return 0;
+ if(! m) return 0;
+ if(! buff) return 0;
- count *= sizeof(T);
- int rest = ((m->rows - row) * m->cols - col) * m->channels() * sizeof(T);
- if(count>rest) count = rest;
- int res = count;
+ count *= sizeof(T);
+ int rest = ((m->rows - row) * m->cols - col) * m->channels() * sizeof(T);
+ if(count>rest) count = rest;
+ int res = count;
- if( m->isContinuous() )
- {
- memcpy(m->ptr(row, col), buff, count);
- } else {
- // row by row
- int num = (m->cols - col - 1) * m->channels() * sizeof(T); // 1st partial row
- if(countptr(row++, col);
- while(count>0){
- memcpy(data, buff, num);
- count -= num;
- buff += num;
- num = m->cols * m->channels() * sizeof(T);
- if(countptr(row++, 0);
- }
- }
- return res;
+ if( m->isContinuous() )
+ {
+ memcpy(m->ptr(row, col), buff, count);
+ } else {
+ // row by row
+ int num = (m->cols - col - 1) * m->channels() * sizeof(T); // 1st partial row
+ if(countptr(row++, col);
+ while(count>0){
+ memcpy(data, buff, num);
+ count -= num;
+ buff += num;
+ num = m->cols * m->channels() * sizeof(T);
+ if(countptr(row++, 0);
+ }
+ }
+ return res;
}
@@ -197,59 +197,59 @@ extern "C" {
#endif
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutB
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_put(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_put(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutS
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_put(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_put(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutI
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_32S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_put(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_32S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_put(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_32F) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_put(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_32F) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_put(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
@@ -260,32 +260,32 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nPutF
template int mat_get(cv::Mat* m, int row, int col, int count, char* buff)
{
- if(! m) return 0;
- if(! buff) return 0;
+ if(! m) return 0;
+ if(! buff) return 0;
- count *= sizeof(T);
- int rest = ((m->rows - row) * m->cols - col) * m->channels() * sizeof(T);
- if(count>rest) count = rest;
- int res = count;
+ count *= sizeof(T);
+ int rest = ((m->rows - row) * m->cols - col) * m->channels() * sizeof(T);
+ if(count>rest) count = rest;
+ int res = count;
- if( m->isContinuous() )
- {
- memcpy(buff, m->ptr(row, col), count);
- } else {
- // row by row
- int num = (m->cols - col - 1) * m->channels() * sizeof(T); // 1st partial row
- if(countptr(row++, col);
- while(count>0){//TODO: recheck this cycle for the case col!=0
- memcpy(buff, data, num);
- count -= num;
- buff += num;
- num = m->cols * m->channels() * sizeof(T);
- if(countptr(row++, 0);
- }
- }
- return res;
+ if( m->isContinuous() )
+ {
+ memcpy(buff, m->ptr(row, col), count);
+ } else {
+ // row by row
+ int num = (m->cols - col - 1) * m->channels() * sizeof(T); // 1st partial row
+ if(countptr(row++, col);
+ while(count>0){//TODO: recheck this cycle for the case col!=0
+ memcpy(buff, data, num);
+ count -= num;
+ buff += num;
+ num = m->cols * m->channels() * sizeof(T);
+ if(countptr(row++, 0);
+ }
+ }
+ return res;
}
#ifdef __cplusplus
@@ -294,98 +294,98 @@ extern "C" {
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetB
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jbyteArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_get(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_8U && me->depth() != CV_8S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_get(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetS
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jshortArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_get(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_16U && me->depth() != CV_16S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_get(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetI
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jintArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_32S) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_get(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_32S) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_get(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetF
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jfloatArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_32F) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_get(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_32F) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_get(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_nGetD
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count, jdoubleArray vals)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->depth() != CV_64F) return 0; // incompatible type
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
-
- char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
- int res = mat_get(me, row, col, count, values);
- env->ReleasePrimitiveArrayCritical(vals, values, 0);
- return res;
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->depth() != CV_64F) return 0; // incompatible type
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+
+ char* values = (char*)env->GetPrimitiveArrayCritical(vals, 0);
+ int res = mat_get(me, row, col, count, values);
+ env->ReleasePrimitiveArrayCritical(vals, values, 0);
+ return res;
}
JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
- (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count)
+ (JNIEnv* env, jclass cls, jlong self, jint row, jint col, jint count)
{
- cv::Mat* me = (cv::Mat*) self;
- if(! self) return 0; // no native object behind
- if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
+ cv::Mat* me = (cv::Mat*) self;
+ if(! self) return 0; // no native object behind
+ if(me->rows<=row || me->cols<=col) return 0; // indexes out of range
- jdoubleArray res = env->NewDoubleArray(me->channels());
- if(res){
- jdouble buff[me->channels()];
- int i;
- switch(me->depth()){
- case CV_8U: for(i=0; ichannels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
- case CV_8S: for(i=0; ichannels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;
- case CV_16U: for(i=0; ichannels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;
- case CV_16S: for(i=0; ichannels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;
- case CV_32S: for(i=0; ichannels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;
- case CV_32F: for(i=0; ichannels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;
- case CV_64F: for(i=0; ichannels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;
- }
- env->SetDoubleArrayRegion(res, 0, me->channels(), buff);
- }
- return res;
+ jdoubleArray res = env->NewDoubleArray(me->channels());
+ if(res){
+ jdouble buff[me->channels()];
+ int i;
+ switch(me->depth()){
+ case CV_8U: for(i=0; ichannels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
+ case CV_8S: for(i=0; ichannels(); i++) buff[i] = *((signed char*) me->ptr(row, col) + i); break;
+ case CV_16U: for(i=0; ichannels(); i++) buff[i] = *((unsigned short*)me->ptr(row, col) + i); break;
+ case CV_16S: for(i=0; ichannels(); i++) buff[i] = *((signed short*) me->ptr(row, col) + i); break;
+ case CV_32S: for(i=0; ichannels(); i++) buff[i] = *((int*) me->ptr(row, col) + i); break;
+ case CV_32F: for(i=0; ichannels(); i++) buff[i] = *((float*) me->ptr(row, col) + i); break;
+ case CV_64F: for(i=0; ichannels(); i++) buff[i] = *((double*) me->ptr(row, col) + i); break;
+ }
+ env->SetDoubleArrayRegion(res, 0, me->channels(), buff);
+ }
+ return res;
}
JNIEXPORT void JNICALL Java_org_opencv_core_Mat_nSetTo
@@ -412,7 +412,7 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_core_Mat_nDot
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCross
- (JNIEnv* env, jclass cls, jlong self, jlong m)
+ (JNIEnv* env, jclass cls, jlong self, jlong m)
{
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
cv::Mat* _m = (cv::Mat*) m; //TODO: check for NULL
@@ -420,10 +420,17 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCross
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nInv
- (JNIEnv* env, jclass cls, jlong self)
+ (JNIEnv* env, jclass cls, jlong self)
{
- cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
- return (jlong) new cv::Mat(me->inv());
+ cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
+ return (jlong) new cv::Mat(me->inv());
+}
+
+JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nReshape
+ (JNIEnv* env, jclass cls, jlong self, jint cn, jint rows)
+{
+ cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
+ return (jlong) new cv::Mat(me->reshape(cn, rows));
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCreateMat__
@@ -441,10 +448,10 @@ JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nEye
JNIEXPORT jstring JNICALL Java_org_opencv_core_Mat_nDump
(JNIEnv *env, jclass cls, jlong self)
{
- cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
+ cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
std::stringstream s;
s << *me;
- return env->NewStringUTF(s.str().c_str());
+ return env->NewStringUTF(s.str().c_str());
}
JNIEXPORT jlong JNICALL Java_org_opencv_core_Mat_nCreateMat__III
diff --git a/modules/java/src/java/core+Mat.java b/modules/java/src/java/core+Mat.java
index 09e8f146e..84b4d52ca 100644
--- a/modules/java/src/java/core+Mat.java
+++ b/modules/java/src/java/core+Mat.java
@@ -275,6 +275,16 @@ public class Mat {
public Mat inv() {
return new Mat( nInv(nativeObj) );
}
+
+ //javadoc:Mat::reshape(cn)
+ public Mat reshape(int cn) {
+ return new Mat( nReshape(nativeObj, cn, 0) );
+ }
+
+ //javadoc:Mat::reshape(cn, rows)
+ public Mat reshape(int cn, int rows) {
+ return new Mat( nReshape(nativeObj, cn, rows) );
+ }
//javadoc:Mat::getNativeObjAddr()
public long getNativeObjAddr() {
@@ -315,6 +325,7 @@ public class Mat {
private static native double nDot(long self, long mat);
private static native long nCross(long self, long mat);
private static native long nInv(long self);
+ private static native long nReshape(long self, int cn, int rows);
private static native long nEye(int rows, int cols, int type);
private static native String nDump(long self);