java: bugfix in RotatedRect, one test fixed

This commit is contained in:
Kirill Kornyakov 2011-08-03 09:43:36 +00:00
parent 69588dfabf
commit 43628ab868
5 changed files with 38 additions and 39 deletions

View File

@ -38,6 +38,7 @@ public class OpenCVTestCase extends TestCase {
// TODO: OpenCVTestCase refactorings // TODO: OpenCVTestCase refactorings
// - rename matrices // - rename matrices
// - create methods gray0() and create src1 explicitly
// - create some masks // - create some masks
// - use truth member everywhere // - use truth member everywhere
@ -82,8 +83,7 @@ public class OpenCVTestCase extends TestCase {
dst = new Mat(); dst = new Mat();
assertTrue(dst.empty()); assertTrue(dst.empty());
truth = new Mat(); truth = null;
assertTrue(truth.empty());
colorBlack = new Scalar(0); colorBlack = new Scalar(0);
@ -96,12 +96,12 @@ public class OpenCVTestCase extends TestCase {
gray128 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128)); gray128 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); 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); grayRnd = new Mat(matSize, matSize, CvType.CV_8U);
Core.randu(grayRnd, 0, 256); 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)); 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)); gray1_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(1.0));
gray3_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(3.0)); gray3_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(3.0));
@ -112,9 +112,9 @@ public class OpenCVTestCase extends TestCase {
grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F); grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F);
Core.randu(grayRnd_32f, 0, 256); 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_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)); 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)); rgba0 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(0));

View File

@ -245,8 +245,7 @@ public class calib3dTest extends OpenCVTestCase {
List<Point> pts1 = new ArrayList<Point>(); List<Point> pts1 = new ArrayList<Point>();
List<Point> pts2 = new ArrayList<Point>(); List<Point> pts2 = new ArrayList<Point>();
int minFundamentalMatPoints = 9; // FIXME: probably should be 8 (see int minFundamentalMatPoints = 9; // FIXME: probably should be 8 (see ticket #1262)
// ticket #1262)
for (int i = 0; i < minFundamentalMatPoints; i++) { for (int i = 0; i < minFundamentalMatPoints; i++) {
double x = Math.random() * 100 - 50; double x = Math.random() * 100 - 50;
double y = Math.random() * 100 - 50; double y = Math.random() * 100 - 50;

View File

@ -141,15 +141,15 @@ public class RotatedRectTest extends OpenCVTestCase {
} }
public void testRotatedRectDoubleArray() { 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); RotatedRect rr = new RotatedRect(vals);
assertNotNull(rr); assertNotNull(rr);
assertEquals(1., rr.center.x); assertEquals(1.5, rr.center.x);
assertEquals(2., rr.center.y); assertEquals(2.6, rr.center.y);
assertEquals(3., rr.size.width); assertEquals(3.7, rr.size.width);
assertEquals(4., rr.size.height); assertEquals(4.2, rr.size.height);
assertEquals(5., rr.angle); assertEquals(5.1, rr.angle);
} }
public void testRotatedRectPointSizeDouble() { public void testRotatedRectPointSizeDouble() {

View File

@ -524,22 +524,22 @@ public class imgprocTest extends OpenCVTestCase {
} }
public void testCornerSubPix() { public void testCornerSubPix() {
Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128)); Mat img = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128));
Point truthPosition = new Point(img.cols()/2, img.rows()/2); Point truthPosition = new Point(img.cols() / 2, img.rows() / 2);
Rect r = new Rect(new Point(0, 0), truthPosition); Rect r = new Rect(new Point(0, 0), truthPosition);
Core.rectangle(img, r.tl(), r.br(), new Scalar(0), -1/*TODO: CV_FILLED*/); Core.rectangle(img, r.tl(), r.br(), new Scalar(0), -1/* TODO: CV_FILLED */);
List<Point> corners = new ArrayList<Point>(); List<Point> corners = new ArrayList<Point>();
corners.add(new Point(truthPosition.x+1, truthPosition.y+1)); corners.add(new Point(truthPosition.x + 1, truthPosition.y + 1));
Size winSize = new Size(2, 2); Size winSize = new Size(2, 2);
Size zeroZone = new Size(-1, -1); Size zeroZone = new Size(-1, -1);
TermCriteria criteria = new TermCriteria(2/*TODO: CV_TERMCRIT_EPS*/, 0, 0.01); TermCriteria criteria = new TermCriteria(2/* TODO: CV_TERMCRIT_EPS */, 0, 0.01);
Imgproc.cornerSubPix(img, corners, winSize, zeroZone, criteria); Imgproc.cornerSubPix(img, corners, winSize, zeroZone, criteria);
assertPointEquals(truthPosition, corners.get(0), weakEPS); assertPointEquals(truthPosition, corners.get(0), weakEPS);
} }
public void testCvtColorMatMatInt() { public void testCvtColorMatMatInt() {
@ -1157,11 +1157,11 @@ public class imgprocTest extends OpenCVTestCase {
cameraMatrix.put(1, 0, 0, 1, 2); cameraMatrix.put(1, 0, 0, 1, 2);
cameraMatrix.put(2, 0, 0, 0, 1); 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(0, 0, 0, 0, 0);
truth.put(1, 0, 0, 0, 0); truth.put(1, 0, 0, 0, 0);
truth.put(2, 0, 0, 3, 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 // TODO: No documentation for this function
// Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, // Imgproc.initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize,
// 5.0, m1type, truthput1, truthput2); // 5.0, m1type, truthput1, truthput2);

View File

@ -26,11 +26,11 @@ public class RotatedRect {
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if(vals!=null) {
center.x = vals.length>0 ? (int)vals[0] : 0; center.x = vals.length>0 ? (double)vals[0] : 0;
center.x = vals.length>1 ? (int)vals[1] : 0; center.y = vals.length>1 ? (double)vals[1] : 0;
size.width = vals.length>2 ? (int)vals[2] : 0; size.width = vals.length>2 ? (double)vals[2] : 0;
size.height = vals.length>3 ? (int)vals[3] : 0; size.height = vals.length>3 ? (double)vals[3] : 0;
angle = vals.length>4 ? (int)vals[4] : 0; angle = vals.length>4 ? (double)vals[4] : 0;
} else { } else {
center.x = 0; center.x = 0;
center.x = 0; center.x = 0;