~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/modules/calib3d/misc/java/test/Calib3dTest.java

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

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