Commit 20b4d0fa authored by Andrey Kamaev's avatar Andrey Kamaev

Added vector_Point2f_to_Mat converter

parent c966d077
......@@ -166,7 +166,6 @@ public class OpenCVTestCase extends TestCase {
}
Mat diff = new Mat();
Core.absdiff(expected, actual, diff);
OpenCVTestRunner.Log(diff + " \n " + diff.dump());
if(isEqualityMeasured)
assertTrue("Max difference between expected and actiual values is bigger than " + eps,
Core.checkRange(diff, true, new Point(), 0.0, eps));
......
package org.opencv.test.calib3d;
import android.util.Log;
import org.opencv.Converters;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Point;
......@@ -8,6 +11,10 @@ import org.opencv.core.Size;
import org.opencv.calib3d.Calib3d;
import org.opencv.core.Core;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import java.util.ArrayList;
import java.util.List;
public class calib3dTest extends OpenCVTestCase {
......@@ -265,7 +272,23 @@ public class calib3dTest extends OpenCVTestCase {
}
public void testFindHomographyMatMat() {
fail("Not yet implemented");
List<Point> originalPoints = new ArrayList<Point>();
List<Point> transformedPoints = new ArrayList<Point>();
for (int i = 0; i < 20; i++){
double x = Math.random() * 100 - 50;
double y = Math.random() * 100 - 50;
originalPoints.add(new Point(x,y));
transformedPoints.add(new Point(y,x));
}
Mat hmg = Calib3d.findHomography(Converters.vector_Point2f_to_Mat(originalPoints), Converters.vector_Point2f_to_Mat(transformedPoints));
truth = new Mat(3,3, CvType.CV_64F);
truth.put(0, 0, 0,1,0,1,0,0,0,0,1);
assertMatEqual(truth, hmg, EPS);
}
public void testFindHomographyMatMatInt() {
......
......@@ -156,7 +156,7 @@ public class coreTest extends OpenCVTestCase {
Mat outOfRange = new Mat(2, 2, CvType.CV_64F);
outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY,
Double.POSITIVE_INFINITY, 0);
assertTrue(Core.checkRange(grayRnd_32f));
assertTrue(Core.checkRange(new Mat()));
assertFalse(Core.checkRange(outOfRange));
......@@ -168,7 +168,7 @@ public class coreTest extends OpenCVTestCase {
Double.POSITIVE_INFINITY, 0);
assertFalse(Core.checkRange(outOfRange, true));
try {
Core.checkRange(outOfRange, false);
fail("Core.checkRange should throw the CvException");
......@@ -1086,8 +1086,39 @@ public class coreTest extends OpenCVTestCase {
}
public void testPerspectiveTransform() {
// nice example
fail("Not yet implemented");
Mat src = new Mat(matSize, matSize, CvType.CV_32FC2);
Mat low = new Mat(1, 1, CvType.CV_32F, new Scalar(0));
Mat high = new Mat(1, 1, CvType.CV_32F, new Scalar(256));
Core.randu(src, low, high);
//FIXME: use Mat.diag
Mat transformMatrix = new Mat(3, 3, CvType.CV_32F);
transformMatrix.put(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
Core.perspectiveTransform(src, dst, transformMatrix);
assertMatEqual(src, dst, EPS);
}
public void testPerspectiveTransform3D() {
Mat src = new Mat(matSize, matSize, CvType.CV_32FC3);
Mat low = new Mat(1, 1, CvType.CV_32F, new Scalar(0));
Mat high = new Mat(1, 1, CvType.CV_32F, new Scalar(256));
Core.randu(src, low, high);
//FIXME: use Mat.diag
Mat transformMatrix = new Mat(4, 4, CvType.CV_32F);
transformMatrix.put(0, 0,
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
Core.perspectiveTransform(src, dst, transformMatrix);
assertMatEqual(src, dst, EPS);
}
public void testPhaseMatMatMat() {
......
This diff is collapsed.
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