• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.opencv.test.calib3d;
2 
3 import java.util.ArrayList;
4 
5 import org.opencv.calib3d.Calib3d;
6 import org.opencv.core.CvType;
7 import org.opencv.core.Mat;
8 import org.opencv.core.MatOfDouble;
9 import org.opencv.core.MatOfPoint2f;
10 import org.opencv.core.MatOfPoint3f;
11 import org.opencv.core.Point;
12 import org.opencv.core.Scalar;
13 import org.opencv.core.Size;
14 import org.opencv.test.OpenCVTestCase;
15 import org.opencv.imgproc.Imgproc;
16 
17 public class Calib3dTest extends OpenCVTestCase {
18 
testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMat()19     public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMat() {
20         fail("Not yet implemented");
21     }
22 
testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMatInt()23     public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMatInt() {
24         fail("Not yet implemented");
25     }
26 
testCalibrationMatrixValues()27     public void testCalibrationMatrixValues() {
28         fail("Not yet implemented");
29     }
30 
testComposeRTMatMatMatMatMatMat()31     public void testComposeRTMatMatMatMatMatMat() {
32         Mat rvec1 = new Mat(3, 1, CvType.CV_32F);
33         rvec1.put(0, 0, 0.5302828, 0.19925919, 0.40105945);
34         Mat tvec1 = new Mat(3, 1, CvType.CV_32F);
35         tvec1.put(0, 0, 0.81438506, 0.43713298, 0.2487897);
36         Mat rvec2 = new Mat(3, 1, CvType.CV_32F);
37         rvec2.put(0, 0, 0.77310503, 0.76209372, 0.30779448);
38         Mat tvec2 = new Mat(3, 1, CvType.CV_32F);
39         tvec2.put(0, 0, 0.70243168, 0.4784472, 0.79219002);
40 
41         Mat rvec3 = new Mat();
42         Mat tvec3 = new Mat();
43 
44         Mat outRvec = new Mat(3, 1, CvType.CV_32F);
45         outRvec.put(0, 0, 1.418641, 0.88665926, 0.56020796);
46         Mat outTvec = new Mat(3, 1, CvType.CV_32F);
47         outTvec.put(0, 0, 1.4560841, 1.0680628, 0.81598103);
48 
49         Calib3d.composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3);
50 
51         assertMatEqual(outRvec, rvec3, EPS);
52         assertMatEqual(outTvec, tvec3, EPS);
53     }
54 
testComposeRTMatMatMatMatMatMatMat()55     public void testComposeRTMatMatMatMatMatMatMat() {
56         fail("Not yet implemented");
57     }
58 
testComposeRTMatMatMatMatMatMatMatMat()59     public void testComposeRTMatMatMatMatMatMatMatMat() {
60         fail("Not yet implemented");
61     }
62 
testComposeRTMatMatMatMatMatMatMatMatMat()63     public void testComposeRTMatMatMatMatMatMatMatMatMat() {
64         fail("Not yet implemented");
65     }
66 
testComposeRTMatMatMatMatMatMatMatMatMatMat()67     public void testComposeRTMatMatMatMatMatMatMatMatMatMat() {
68         fail("Not yet implemented");
69     }
70 
testComposeRTMatMatMatMatMatMatMatMatMatMatMat()71     public void testComposeRTMatMatMatMatMatMatMatMatMatMatMat() {
72         fail("Not yet implemented");
73     }
74 
testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat()75     public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat() {
76         fail("Not yet implemented");
77     }
78 
testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat()79     public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat() {
80         fail("Not yet implemented");
81     }
82 
testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat()83     public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat() {
84         fail("Not yet implemented");
85         // Mat dr3dr1;
86         // Mat dr3dt1;
87         // Mat dr3dr2;
88         // Mat dr3dt2;
89         // Mat dt3dr1;
90         // Mat dt3dt1;
91         // Mat dt3dr2;
92         // Mat dt3dt2;
93         // , dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2);
94         // [0.97031879, -0.091774099, 0.38594806;
95         // 0.15181915, 0.98091727, -0.44186208;
96         // -0.39509675, 0.43839464, 0.93872648]
97         // [0, 0, 0;
98         // 0, 0, 0;
99         // 0, 0, 0]
100         // [1.0117353, 0.16348237, -0.083180845;
101         // -0.1980398, 1.006078, 0.30299222;
102         // 0.075766489, -0.32784501, 1.0163091]
103         // [0, 0, 0;
104         // 0, 0, 0;
105         // 0, 0, 0]
106         // [0, 0, 0;
107         // 0, 0, 0;
108         // 0, 0, 0]
109         // [0.69658804, 0.018115902, 0.7172426;
110         // 0.51114357, 0.68899536, -0.51382649;
111         // -0.50348526, 0.72453934, 0.47068608]
112         // [0.18536358, -0.20515044, -0.48834875;
113         // -0.25120571, 0.29043972, 0.60573936;
114         // 0.35370794, -0.69923931, 0.45781645]
115         // [1, 0, 0;
116         // 0, 1, 0;
117         // 0, 0, 1]
118     }
119 
testConvertPointsFromHomogeneous()120     public void testConvertPointsFromHomogeneous() {
121         fail("Not yet implemented");
122     }
123 
testConvertPointsToHomogeneous()124     public void testConvertPointsToHomogeneous() {
125         fail("Not yet implemented");
126     }
127 
testDecomposeProjectionMatrixMatMatMatMat()128     public void testDecomposeProjectionMatrixMatMatMatMat() {
129         fail("Not yet implemented");
130     }
131 
testDecomposeProjectionMatrixMatMatMatMatMat()132     public void testDecomposeProjectionMatrixMatMatMatMatMat() {
133         fail("Not yet implemented");
134     }
135 
testDecomposeProjectionMatrixMatMatMatMatMatMat()136     public void testDecomposeProjectionMatrixMatMatMatMatMatMat() {
137         fail("Not yet implemented");
138     }
139 
testDecomposeProjectionMatrixMatMatMatMatMatMatMat()140     public void testDecomposeProjectionMatrixMatMatMatMatMatMatMat() {
141         fail("Not yet implemented");
142     }
143 
testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat()144     public void testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat() {
145         fail("Not yet implemented");
146     }
147 
testDrawChessboardCorners()148     public void testDrawChessboardCorners() {
149         fail("Not yet implemented");
150     }
151 
testEstimateAffine3DMatMatMatMat()152     public void testEstimateAffine3DMatMatMatMat() {
153         fail("Not yet implemented");
154     }
155 
testEstimateAffine3DMatMatMatMatDouble()156     public void testEstimateAffine3DMatMatMatMatDouble() {
157         fail("Not yet implemented");
158     }
159 
testEstimateAffine3DMatMatMatMatDoubleDouble()160     public void testEstimateAffine3DMatMatMatMatDoubleDouble() {
161         fail("Not yet implemented");
162     }
163 
testFilterSpecklesMatDoubleIntDouble()164     public void testFilterSpecklesMatDoubleIntDouble() {
165         gray_16s_1024.copyTo(dst);
166         Point center = new Point(gray_16s_1024.rows() / 2., gray_16s_1024.cols() / 2.);
167         Imgproc.circle(dst, center, 1, Scalar.all(4096));
168 
169         assertMatNotEqual(gray_16s_1024, dst);
170         Calib3d.filterSpeckles(dst, 1024.0, 100, 0.);
171         assertMatEqual(gray_16s_1024, dst);
172     }
173 
testFilterSpecklesMatDoubleIntDoubleMat()174     public void testFilterSpecklesMatDoubleIntDoubleMat() {
175         fail("Not yet implemented");
176     }
177 
testFindChessboardCornersMatSizeMat()178     public void testFindChessboardCornersMatSizeMat() {
179         Size patternSize = new Size(9, 6);
180         MatOfPoint2f corners = new MatOfPoint2f();
181         Calib3d.findChessboardCorners(grayChess, patternSize, corners);
182         assertFalse(corners.empty());
183     }
184 
testFindChessboardCornersMatSizeMatInt()185     public void testFindChessboardCornersMatSizeMatInt() {
186         Size patternSize = new Size(9, 6);
187         MatOfPoint2f corners = new MatOfPoint2f();
188         Calib3d.findChessboardCorners(grayChess, patternSize, corners, Calib3d.CALIB_CB_ADAPTIVE_THRESH + Calib3d.CALIB_CB_NORMALIZE_IMAGE
189                 + Calib3d.CALIB_CB_FAST_CHECK);
190         assertFalse(corners.empty());
191     }
192 
testFind4QuadCornerSubpix()193     public void testFind4QuadCornerSubpix() {
194         Size patternSize = new Size(9, 6);
195         MatOfPoint2f corners = new MatOfPoint2f();
196         Size region_size = new Size(5, 5);
197         Calib3d.findChessboardCorners(grayChess, patternSize, corners);
198         Calib3d.find4QuadCornerSubpix(grayChess, corners, region_size);
199         assertFalse(corners.empty());
200     }
201 
testFindCirclesGridMatSizeMat()202     public void testFindCirclesGridMatSizeMat() {
203         int size = 300;
204         Mat img = new Mat(size, size, CvType.CV_8U);
205         img.setTo(new Scalar(255));
206         Mat centers = new Mat();
207 
208         assertFalse(Calib3d.findCirclesGrid(img, new Size(5, 5), centers));
209 
210         for (int i = 0; i < 5; i++)
211             for (int j = 0; j < 5; j++) {
212                 Point pt = new Point(size * (2 * i + 1) / 10, size * (2 * j + 1) / 10);
213                 Imgproc.circle(img, pt, 10, new Scalar(0), -1);
214             }
215 
216         assertTrue(Calib3d.findCirclesGrid(img, new Size(5, 5), centers));
217 
218         assertEquals(25, centers.rows());
219         assertEquals(1, centers.cols());
220         assertEquals(CvType.CV_32FC2, centers.type());
221     }
222 
testFindCirclesGridMatSizeMatInt()223     public void testFindCirclesGridMatSizeMatInt() {
224         int size = 300;
225         Mat img = new Mat(size, size, CvType.CV_8U);
226         img.setTo(new Scalar(255));
227         Mat centers = new Mat();
228 
229         assertFalse(Calib3d.findCirclesGrid(img, new Size(3, 5), centers, Calib3d.CALIB_CB_CLUSTERING
230                 | Calib3d.CALIB_CB_ASYMMETRIC_GRID));
231 
232         int step = size * 2 / 15;
233         int offsetx = size / 6;
234         int offsety = (size - 4 * step) / 2;
235         for (int i = 0; i < 3; i++)
236             for (int j = 0; j < 5; j++) {
237                 Point pt = new Point(offsetx + (2 * i + j % 2) * step, offsety + step * j);
238                 Imgproc.circle(img, pt, 10, new Scalar(0), -1);
239             }
240 
241         assertTrue(Calib3d.findCirclesGrid(img, new Size(3, 5), centers, Calib3d.CALIB_CB_CLUSTERING
242                 | Calib3d.CALIB_CB_ASYMMETRIC_GRID));
243 
244         assertEquals(15, centers.rows());
245         assertEquals(1, centers.cols());
246         assertEquals(CvType.CV_32FC2, centers.type());
247     }
248 
testFindFundamentalMatListOfPointListOfPoint()249     public void testFindFundamentalMatListOfPointListOfPoint() {
250         fail("Not yet implemented");
251 /*
252         int minFundamentalMatPoints = 8;
253 
254         MatOfPoint2f pts = new MatOfPoint2f();
255         pts.alloc(minFundamentalMatPoints);
256 
257         for (int i = 0; i < minFundamentalMatPoints; i++) {
258             double x = Math.random() * 100 - 50;
259             double y = Math.random() * 100 - 50;
260             pts.put(i, 0, x, y); //add(new Point(x, y));
261         }
262 
263         Mat fm = Calib3d.findFundamentalMat(pts, pts);
264 
265         truth = new Mat(3, 3, CvType.CV_64F);
266         truth.put(0, 0, 0, -0.577, 0.288, 0.577, 0, 0.288, -0.288, -0.288, 0);
267         assertMatEqual(truth, fm, EPS);
268 */
269     }
270 
testFindFundamentalMatListOfPointListOfPointInt()271     public void testFindFundamentalMatListOfPointListOfPointInt() {
272         fail("Not yet implemented");
273     }
274 
testFindFundamentalMatListOfPointListOfPointIntDouble()275     public void testFindFundamentalMatListOfPointListOfPointIntDouble() {
276         fail("Not yet implemented");
277     }
278 
testFindFundamentalMatListOfPointListOfPointIntDoubleDouble()279     public void testFindFundamentalMatListOfPointListOfPointIntDoubleDouble() {
280         fail("Not yet implemented");
281     }
282 
testFindFundamentalMatListOfPointListOfPointIntDoubleDoubleMat()283     public void testFindFundamentalMatListOfPointListOfPointIntDoubleDoubleMat() {
284         fail("Not yet implemented");
285     }
286 
testFindHomographyListOfPointListOfPoint()287     public void testFindHomographyListOfPointListOfPoint() {
288         final int NUM = 20;
289 
290         MatOfPoint2f originalPoints = new MatOfPoint2f();
291         originalPoints.alloc(NUM);
292         MatOfPoint2f transformedPoints = new MatOfPoint2f();
293         transformedPoints.alloc(NUM);
294 
295         for (int i = 0; i < NUM; i++) {
296             double x = Math.random() * 100 - 50;
297             double y = Math.random() * 100 - 50;
298             originalPoints.put(i, 0, x, y);
299             transformedPoints.put(i, 0, y, x);
300         }
301 
302         Mat hmg = Calib3d.findHomography(originalPoints, transformedPoints);
303 
304         truth = new Mat(3, 3, CvType.CV_64F);
305         truth.put(0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1);
306 
307         assertMatEqual(truth, hmg, EPS);
308     }
309 
testFindHomographyListOfPointListOfPointInt()310     public void testFindHomographyListOfPointListOfPointInt() {
311         fail("Not yet implemented");
312     }
313 
testFindHomographyListOfPointListOfPointIntDouble()314     public void testFindHomographyListOfPointListOfPointIntDouble() {
315         fail("Not yet implemented");
316     }
317 
testFindHomographyListOfPointListOfPointIntDoubleMat()318     public void testFindHomographyListOfPointListOfPointIntDoubleMat() {
319         fail("Not yet implemented");
320     }
321 
testGetOptimalNewCameraMatrixMatMatSizeDouble()322     public void testGetOptimalNewCameraMatrixMatMatSizeDouble() {
323         fail("Not yet implemented");
324     }
325 
testGetOptimalNewCameraMatrixMatMatSizeDoubleSize()326     public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSize() {
327         fail("Not yet implemented");
328     }
329 
testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRect()330     public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRect() {
331         fail("Not yet implemented");
332     }
333 
testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRectBoolean()334     public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRectBoolean() {
335         fail("Not yet implemented");
336     }
337 
testGetValidDisparityROI()338     public void testGetValidDisparityROI() {
339         fail("Not yet implemented");
340     }
341 
testInitCameraMatrix2DListOfMatListOfMatSize()342     public void testInitCameraMatrix2DListOfMatListOfMatSize() {
343         fail("Not yet implemented");
344     }
345 
testInitCameraMatrix2DListOfMatListOfMatSizeDouble()346     public void testInitCameraMatrix2DListOfMatListOfMatSizeDouble() {
347         fail("Not yet implemented");
348     }
349 
testMatMulDeriv()350     public void testMatMulDeriv() {
351         fail("Not yet implemented");
352     }
353 
testProjectPointsMatMatMatMatMatMat()354     public void testProjectPointsMatMatMatMatMatMat() {
355         fail("Not yet implemented");
356     }
357 
testProjectPointsMatMatMatMatMatMatMat()358     public void testProjectPointsMatMatMatMatMatMatMat() {
359         fail("Not yet implemented");
360     }
361 
testProjectPointsMatMatMatMatMatMatMatDouble()362     public void testProjectPointsMatMatMatMatMatMatMatDouble() {
363         fail("Not yet implemented");
364     }
365 
testRectify3Collinear()366     public void testRectify3Collinear() {
367         fail("Not yet implemented");
368     }
369 
testReprojectImageTo3DMatMatMat()370     public void testReprojectImageTo3DMatMatMat() {
371         Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
372         transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
373 
374         Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
375 
376         float[] disp = new float[matSize * matSize];
377         for (int i = 0; i < matSize; i++)
378             for (int j = 0; j < matSize; j++)
379                 disp[i * matSize + j] = i - j;
380         disparity.put(0, 0, disp);
381 
382         Mat _3dPoints = new Mat();
383 
384         Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix);
385 
386         assertEquals(CvType.CV_32FC3, _3dPoints.type());
387         assertEquals(matSize, _3dPoints.rows());
388         assertEquals(matSize, _3dPoints.cols());
389 
390         truth = new Mat(matSize, matSize, CvType.CV_32FC3);
391 
392         float[] _truth = new float[matSize * matSize * 3];
393         for (int i = 0; i < matSize; i++)
394             for (int j = 0; j < matSize; j++) {
395                 _truth[(i * matSize + j) * 3 + 0] = i;
396                 _truth[(i * matSize + j) * 3 + 1] = j;
397                 _truth[(i * matSize + j) * 3 + 2] = i - j;
398             }
399         truth.put(0, 0, _truth);
400 
401         assertMatEqual(truth, _3dPoints, EPS);
402     }
403 
testReprojectImageTo3DMatMatMatBoolean()404     public void testReprojectImageTo3DMatMatMatBoolean() {
405         Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
406         transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
407 
408         Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
409 
410         float[] disp = new float[matSize * matSize];
411         for (int i = 0; i < matSize; i++)
412             for (int j = 0; j < matSize; j++)
413                 disp[i * matSize + j] = i - j;
414         disp[0] = -Float.MAX_VALUE;
415         disparity.put(0, 0, disp);
416 
417         Mat _3dPoints = new Mat();
418 
419         Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, true);
420 
421         assertEquals(CvType.CV_32FC3, _3dPoints.type());
422         assertEquals(matSize, _3dPoints.rows());
423         assertEquals(matSize, _3dPoints.cols());
424 
425         truth = new Mat(matSize, matSize, CvType.CV_32FC3);
426 
427         float[] _truth = new float[matSize * matSize * 3];
428         for (int i = 0; i < matSize; i++)
429             for (int j = 0; j < matSize; j++) {
430                 _truth[(i * matSize + j) * 3 + 0] = i;
431                 _truth[(i * matSize + j) * 3 + 1] = j;
432                 _truth[(i * matSize + j) * 3 + 2] = i - j;
433             }
434         _truth[2] = 10000;
435         truth.put(0, 0, _truth);
436 
437         assertMatEqual(truth, _3dPoints, EPS);
438     }
439 
testReprojectImageTo3DMatMatMatBooleanInt()440     public void testReprojectImageTo3DMatMatMatBooleanInt() {
441         Mat transformMatrix = new Mat(4, 4, CvType.CV_64F);
442         transformMatrix.put(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
443 
444         Mat disparity = new Mat(matSize, matSize, CvType.CV_32F);
445 
446         float[] disp = new float[matSize * matSize];
447         for (int i = 0; i < matSize; i++)
448             for (int j = 0; j < matSize; j++)
449                 disp[i * matSize + j] = i - j;
450         disparity.put(0, 0, disp);
451 
452         Mat _3dPoints = new Mat();
453 
454         Calib3d.reprojectImageTo3D(disparity, _3dPoints, transformMatrix, false, CvType.CV_16S);
455 
456         assertEquals(CvType.CV_16SC3, _3dPoints.type());
457         assertEquals(matSize, _3dPoints.rows());
458         assertEquals(matSize, _3dPoints.cols());
459 
460         truth = new Mat(matSize, matSize, CvType.CV_16SC3);
461 
462         short[] _truth = new short[matSize * matSize * 3];
463         for (short i = 0; i < matSize; i++)
464             for (short j = 0; j < matSize; j++) {
465                 _truth[(i * matSize + j) * 3 + 0] = i;
466                 _truth[(i * matSize + j) * 3 + 1] = j;
467                 _truth[(i * matSize + j) * 3 + 2] = (short) (i - j);
468             }
469         truth.put(0, 0, _truth);
470 
471         assertMatEqual(truth, _3dPoints, EPS);
472     }
473 
testRodriguesMatMat()474     public void testRodriguesMatMat() {
475         Mat r = new Mat(3, 1, CvType.CV_32F);
476         Mat R = new Mat(3, 3, CvType.CV_32F);
477 
478         r.put(0, 0, Math.PI, 0, 0);
479 
480         Calib3d.Rodrigues(r, R);
481 
482         truth = new Mat(3, 3, CvType.CV_32F);
483         truth.put(0, 0, 1, 0, 0, 0, -1, 0, 0, 0, -1);
484         assertMatEqual(truth, R, EPS);
485 
486         Mat r2 = new Mat();
487         Calib3d.Rodrigues(R, r2);
488 
489         assertMatEqual(r, r2, EPS);
490     }
491 
testRodriguesMatMatMat()492     public void testRodriguesMatMatMat() {
493         fail("Not yet implemented");
494     }
495 
testRQDecomp3x3MatMatMat()496     public void testRQDecomp3x3MatMatMat() {
497         fail("Not yet implemented");
498     }
499 
testRQDecomp3x3MatMatMatMat()500     public void testRQDecomp3x3MatMatMatMat() {
501         fail("Not yet implemented");
502     }
503 
testRQDecomp3x3MatMatMatMatMat()504     public void testRQDecomp3x3MatMatMatMatMat() {
505         fail("Not yet implemented");
506     }
507 
testRQDecomp3x3MatMatMatMatMatMat()508     public void testRQDecomp3x3MatMatMatMatMatMat() {
509         fail("Not yet implemented");
510     }
511 
testSolvePnPListOfPoint3ListOfPointMatMatMatMat()512     public void testSolvePnPListOfPoint3ListOfPointMatMatMatMat() {
513         Mat intrinsics = Mat.eye(3, 3, CvType.CV_64F);
514         intrinsics.put(0, 0, 400);
515         intrinsics.put(1, 1, 400);
516         intrinsics.put(0, 2, 640 / 2);
517         intrinsics.put(1, 2, 480 / 2);
518 
519         final int minPnpPointsNum = 4;
520 
521         MatOfPoint3f points3d = new MatOfPoint3f();
522         points3d.alloc(minPnpPointsNum);
523         MatOfPoint2f points2d = new MatOfPoint2f();
524         points2d.alloc(minPnpPointsNum);
525 
526         for (int i = 0; i < minPnpPointsNum; i++) {
527             double x = Math.random() * 100 - 50;
528             double y = Math.random() * 100 - 50;
529             points2d.put(i, 0, x, y); //add(new Point(x, y));
530             points3d.put(i, 0, 0, y, x); // add(new Point3(0, y, x));
531         }
532 
533         Mat rvec = new Mat();
534         Mat tvec = new Mat();
535         Calib3d.solvePnP(points3d, points2d, intrinsics, new MatOfDouble(), rvec, tvec);
536 
537         Mat truth_rvec = new Mat(3, 1, CvType.CV_64F);
538         truth_rvec.put(0, 0, 0, Math.PI / 2, 0);
539 
540         Mat truth_tvec = new Mat(3, 1, CvType.CV_64F);
541         truth_tvec.put(0, 0, -320, -240, 400);
542 
543         assertMatEqual(truth_rvec, rvec, EPS);
544         assertMatEqual(truth_tvec, tvec, EPS);
545     }
546 
testSolvePnPListOfPoint3ListOfPointMatMatMatMatBoolean()547     public void testSolvePnPListOfPoint3ListOfPointMatMatMatMatBoolean() {
548         fail("Not yet implemented");
549     }
550 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMat()551     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMat() {
552         fail("Not yet implemented");
553     }
554 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBoolean()555     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBoolean() {
556         fail("Not yet implemented");
557     }
558 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanInt()559     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanInt() {
560         fail("Not yet implemented");
561     }
562 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloat()563     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloat() {
564         fail("Not yet implemented");
565     }
566 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatInt()567     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatInt() {
568         fail("Not yet implemented");
569     }
570 
testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatIntMat()571     public void testSolvePnPRansacListOfPoint3ListOfPointMatMatMatMatBooleanIntFloatIntMat() {
572         fail("Not yet implemented");
573     }
574 
testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMat()575     public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMat() {
576         fail("Not yet implemented");
577     }
578 
testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteria()579     public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteria() {
580         fail("Not yet implemented");
581     }
582 
testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteriaInt()583     public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteriaInt() {
584         fail("Not yet implemented");
585     }
586 
testStereoRectifyUncalibratedMatMatMatSizeMatMat()587     public void testStereoRectifyUncalibratedMatMatMatSizeMatMat() {
588         fail("Not yet implemented");
589     }
590 
testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble()591     public void testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble() {
592         fail("Not yet implemented");
593     }
594 
testValidateDisparityMatMatIntInt()595     public void testValidateDisparityMatMatIntInt() {
596         fail("Not yet implemented");
597     }
598 
testValidateDisparityMatMatIntIntInt()599     public void testValidateDisparityMatMatIntIntInt() {
600         fail("Not yet implemented");
601     }
602 
testComputeCorrespondEpilines()603     public void testComputeCorrespondEpilines()
604     {
605         Mat fundamental = new Mat(3, 3, CvType.CV_64F);
606         fundamental.put(0, 0, 0, -0.577, 0.288, 0.577, 0, 0.288, -0.288, -0.288, 0);
607         MatOfPoint2f left = new MatOfPoint2f();
608         left.alloc(1);
609         left.put(0, 0, 2, 3); //add(new Point(x, y));
610         Mat lines = new Mat();
611         Mat truth = new Mat(1, 1, CvType.CV_32FC3);
612         truth.put(0, 0, -0.70735186, 0.70686162, -0.70588124);
613         Calib3d.computeCorrespondEpilines(left, 1, fundamental, lines);
614         assertMatEqual(truth, lines, EPS);
615     }
616 
testConstants()617     public void testConstants()
618     {
619         // calib3d.hpp: some constants have conflict with constants from 'fisheye' namespace
620         assertEquals(1, Calib3d.CALIB_USE_INTRINSIC_GUESS);
621         assertEquals(2, Calib3d.CALIB_FIX_ASPECT_RATIO);
622         assertEquals(4, Calib3d.CALIB_FIX_PRINCIPAL_POINT);
623         assertEquals(8, Calib3d.CALIB_ZERO_TANGENT_DIST);
624         assertEquals(16, Calib3d.CALIB_FIX_FOCAL_LENGTH);
625         assertEquals(32, Calib3d.CALIB_FIX_K1);
626         assertEquals(64, Calib3d.CALIB_FIX_K2);
627         assertEquals(128, Calib3d.CALIB_FIX_K3);
628         assertEquals(0x0800, Calib3d.CALIB_FIX_K4);
629         assertEquals(0x1000, Calib3d.CALIB_FIX_K5);
630         assertEquals(0x2000, Calib3d.CALIB_FIX_K6);
631         assertEquals(0x4000, Calib3d.CALIB_RATIONAL_MODEL);
632         assertEquals(0x8000, Calib3d.CALIB_THIN_PRISM_MODEL);
633         assertEquals(0x10000, Calib3d.CALIB_FIX_S1_S2_S3_S4);
634         assertEquals(0x40000, Calib3d.CALIB_TILTED_MODEL);
635         assertEquals(0x80000, Calib3d.CALIB_FIX_TAUX_TAUY);
636         assertEquals(0x100000, Calib3d.CALIB_USE_QR);
637         assertEquals(0x200000, Calib3d.CALIB_FIX_TANGENT_DIST);
638         assertEquals(0x100, Calib3d.CALIB_FIX_INTRINSIC);
639         assertEquals(0x200, Calib3d.CALIB_SAME_FOCAL_LENGTH);
640         assertEquals(0x400, Calib3d.CALIB_ZERO_DISPARITY);
641         assertEquals((1 << 17), Calib3d.CALIB_USE_LU);
642         assertEquals((1 << 22), Calib3d.CALIB_USE_EXTRINSIC_GUESS);
643     }
644 
testSolvePnPGeneric_regression_16040()645     public void testSolvePnPGeneric_regression_16040() {
646         Mat intrinsics = Mat.eye(3, 3, CvType.CV_64F);
647         intrinsics.put(0, 0, 400);
648         intrinsics.put(1, 1, 400);
649         intrinsics.put(0, 2, 640 / 2);
650         intrinsics.put(1, 2, 480 / 2);
651 
652         final int minPnpPointsNum = 4;
653 
654         MatOfPoint3f points3d = new MatOfPoint3f();
655         points3d.alloc(minPnpPointsNum);
656         MatOfPoint2f points2d = new MatOfPoint2f();
657         points2d.alloc(minPnpPointsNum);
658 
659         for (int i = 0; i < minPnpPointsNum; i++) {
660             double x = Math.random() * 100 - 50;
661             double y = Math.random() * 100 - 50;
662             points2d.put(i, 0, x, y); //add(new Point(x, y));
663             points3d.put(i, 0, 0, y, x); // add(new Point3(0, y, x));
664         }
665 
666         ArrayList<Mat> rvecs = new ArrayList<Mat>();
667         ArrayList<Mat> tvecs = new ArrayList<Mat>();
668 
669         Mat rvec = new Mat();
670         Mat tvec = new Mat();
671 
672         Mat reprojectionError = new Mat(2, 1, CvType.CV_64FC1);
673 
674         Calib3d.solvePnPGeneric(points3d, points2d, intrinsics, new MatOfDouble(), rvecs, tvecs, false, Calib3d.SOLVEPNP_IPPE, rvec, tvec, reprojectionError);
675 
676         Mat truth_rvec = new Mat(3, 1, CvType.CV_64F);
677         truth_rvec.put(0, 0, 0, Math.PI / 2, 0);
678 
679         Mat truth_tvec = new Mat(3, 1, CvType.CV_64F);
680         truth_tvec.put(0, 0, -320, -240, 400);
681 
682         assertMatEqual(truth_rvec, rvecs.get(0), 10 * EPS);
683         assertMatEqual(truth_tvec, tvecs.get(0), 1000 * EPS);
684     }
685 }
686