java: bugfix in RotatedRect, one test fixed
This commit is contained in:
parent
69588dfabf
commit
43628ab868
@ -38,6 +38,7 @@ public class OpenCVTestCase extends TestCase {
|
||||
|
||||
// TODO: OpenCVTestCase refactorings
|
||||
// - rename matrices
|
||||
// - create methods gray0() and create src1 explicitly
|
||||
// - create some masks
|
||||
// - use truth member everywhere
|
||||
|
||||
@ -82,8 +83,7 @@ public class OpenCVTestCase extends TestCase {
|
||||
|
||||
dst = new Mat();
|
||||
assertTrue(dst.empty());
|
||||
truth = new Mat();
|
||||
assertTrue(truth.empty());
|
||||
truth = null;
|
||||
|
||||
colorBlack = new Scalar(0);
|
||||
|
||||
@ -96,11 +96,11 @@ public class OpenCVTestCase extends TestCase {
|
||||
gray128 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
|
||||
gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
|
||||
|
||||
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256));
|
||||
gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar(1024));
|
||||
|
||||
grayRnd = new Mat(matSize, matSize, CvType.CV_8U);
|
||||
Core.randu(grayRnd, 0, 256);
|
||||
|
||||
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256));
|
||||
gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar(1024));
|
||||
|
||||
gray0_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(0.0));
|
||||
gray1_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(1.0));
|
||||
@ -112,9 +112,9 @@ public class OpenCVTestCase extends TestCase {
|
||||
grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F);
|
||||
Core.randu(grayRnd_32f, 0, 256);
|
||||
|
||||
gray0_32f_1d = new Mat(1, matSize, CvType.CV_32F, new Scalar(0.0));
|
||||
|
||||
gray0_64f = new Mat(matSize, matSize, CvType.CV_64F, new Scalar(0.0));
|
||||
|
||||
gray0_32f_1d = new Mat(1, matSize, CvType.CV_32F, new Scalar(0.0));
|
||||
gray0_64f_1d = new Mat(1, matSize, CvType.CV_64F, new Scalar(0.0));
|
||||
|
||||
rgba0 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(0));
|
||||
@ -224,7 +224,7 @@ public class OpenCVTestCase extends TestCase {
|
||||
assertEquals(expected.width, actual.width);
|
||||
assertEquals(expected.height, actual.height);
|
||||
}
|
||||
|
||||
|
||||
public static void assertMatEqual(Mat m1, Mat m2) {
|
||||
compareMats(m1, m2, true);
|
||||
}
|
||||
|
@ -245,8 +245,7 @@ public class calib3dTest extends OpenCVTestCase {
|
||||
List<Point> pts1 = new ArrayList<Point>();
|
||||
List<Point> pts2 = new ArrayList<Point>();
|
||||
|
||||
int minFundamentalMatPoints = 9; // FIXME: probably should be 8 (see
|
||||
// ticket #1262)
|
||||
int minFundamentalMatPoints = 9; // FIXME: probably should be 8 (see ticket #1262)
|
||||
for (int i = 0; i < minFundamentalMatPoints; i++) {
|
||||
double x = Math.random() * 100 - 50;
|
||||
double y = Math.random() * 100 - 50;
|
||||
|
@ -141,15 +141,15 @@ public class RotatedRectTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRotatedRectDoubleArray() {
|
||||
double[] vals = {1, 2, 3, 4, 5};
|
||||
double[] vals = {1.5, 2.6, 3.7, 4.2, 5.1};
|
||||
RotatedRect rr = new RotatedRect(vals);
|
||||
|
||||
assertNotNull(rr);
|
||||
assertEquals(1., rr.center.x);
|
||||
assertEquals(2., rr.center.y);
|
||||
assertEquals(3., rr.size.width);
|
||||
assertEquals(4., rr.size.height);
|
||||
assertEquals(5., rr.angle);
|
||||
assertEquals(1.5, rr.center.x);
|
||||
assertEquals(2.6, rr.center.y);
|
||||
assertEquals(3.7, rr.size.width);
|
||||
assertEquals(4.2, rr.size.height);
|
||||
assertEquals(5.1, rr.angle);
|
||||
}
|
||||
|
||||
public void testRotatedRectPointSizeDouble() {
|
||||
|
@ -524,22 +524,22 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testCornerSubPix() {
|
||||
Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
|
||||
|
||||
Point truthPosition = new Point(img.cols()/2, img.rows()/2);
|
||||
|
||||
Rect r = new Rect(new Point(0, 0), truthPosition);
|
||||
Core.rectangle(img, r.tl(), r.br(), new Scalar(0), -1/*TODO: CV_FILLED*/);
|
||||
|
||||
List<Point> corners = new ArrayList<Point>();
|
||||
corners.add(new Point(truthPosition.x+1, truthPosition.y+1));
|
||||
|
||||
Size winSize = new Size(2, 2);
|
||||
Size zeroZone = new Size(-1, -1);
|
||||
TermCriteria criteria = new TermCriteria(2/*TODO: CV_TERMCRIT_EPS*/, 0, 0.01);
|
||||
|
||||
Imgproc.cornerSubPix(img, corners, winSize, zeroZone, criteria);
|
||||
assertPointEquals(truthPosition, corners.get(0), weakEPS);
|
||||
Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
|
||||
|
||||
Point truthPosition = new Point(img.cols() / 2, img.rows() / 2);
|
||||
|
||||
Rect r = new Rect(new Point(0, 0), truthPosition);
|
||||
Core.rectangle(img, r.tl(), r.br(), new Scalar(0), -1/* TODO: CV_FILLED */);
|
||||
|
||||
List<Point> corners = new ArrayList<Point>();
|
||||
corners.add(new Point(truthPosition.x + 1, truthPosition.y + 1));
|
||||
|
||||
Size winSize = new Size(2, 2);
|
||||
Size zeroZone = new Size(-1, -1);
|
||||
TermCriteria criteria = new TermCriteria(2/* TODO: CV_TERMCRIT_EPS */, 0, 0.01);
|
||||
|
||||
Imgproc.cornerSubPix(img, corners, winSize, zeroZone, criteria);
|
||||
assertPointEquals(truthPosition, corners.get(0), weakEPS);
|
||||
}
|
||||
|
||||
public void testCvtColorMatMatInt() {
|
||||
@ -1157,11 +1157,11 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
cameraMatrix.put(1, 0, 0, 1, 2);
|
||||
cameraMatrix.put(2, 0, 0, 0, 1);
|
||||
|
||||
distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4);
|
||||
truth = new Mat(3, 3, CvType.CV_32F);
|
||||
truth.put(0, 0, 0, 0, 0);
|
||||
truth.put(1, 0, 0, 0, 0);
|
||||
truth.put(2, 0, 0, 3, 0);
|
||||
|
||||
distCoeffs.put(0, 0, 1.0, 3.0, 2.0, 4);
|
||||
// TODO: No documentation for this function
|
||||
// Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize,
|
||||
// 5.0, m1type, truthput1, truthput2);
|
||||
|
@ -26,11 +26,11 @@ public class RotatedRect {
|
||||
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
center.x = vals.length>0 ? (int)vals[0] : 0;
|
||||
center.x = vals.length>1 ? (int)vals[1] : 0;
|
||||
size.width = vals.length>2 ? (int)vals[2] : 0;
|
||||
size.height = vals.length>3 ? (int)vals[3] : 0;
|
||||
angle = vals.length>4 ? (int)vals[4] : 0;
|
||||
center.x = vals.length>0 ? (double)vals[0] : 0;
|
||||
center.y = vals.length>1 ? (double)vals[1] : 0;
|
||||
size.width = vals.length>2 ? (double)vals[2] : 0;
|
||||
size.height = vals.length>3 ? (double)vals[3] : 0;
|
||||
angle = vals.length>4 ? (double)vals[4] : 0;
|
||||
} else {
|
||||
center.x = 0;
|
||||
center.x = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user