mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #15595 from frastlin:rodrigues
* Added Rodrigues to the JS embindgen.py and a unittest in test_calib3d.js on 3.4 base
This commit is contained in:
parent
7ce9428e96
commit
25dee8383c
@ -143,7 +143,7 @@ features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptor
|
||||
'BFMatcher': ['isMaskSupported', 'create'],
|
||||
'': ['drawKeypoints', 'drawMatches', 'drawMatchesKnn']}
|
||||
|
||||
calib3d = {'': ['findHomography']}
|
||||
calib3d = {'': ['findHomography', 'Rodrigues']}
|
||||
|
||||
def makeWhiteList(module_list):
|
||||
wl = {}
|
||||
|
@ -41,3 +41,27 @@ QUnit.test('findHomography', function(assert) {
|
||||
|
||||
assert.ok(mat instanceof cv.Mat);
|
||||
});
|
||||
|
||||
QUnit.test('Rodrigues', function(assert) {
|
||||
// Converts a rotation matrix to a rotation vector and vice versa
|
||||
// data64F is the output array
|
||||
const rvec0 = cv.matFromArray(1, 3, cv.CV_64F, [1,1,1]);
|
||||
let rMat0 = new cv.Mat();
|
||||
let rvec1 = new cv.Mat();
|
||||
|
||||
// Args: input Mat, output Mat. The function mutates the output Mat, so the function does not return anything.
|
||||
// cv.Rodrigues (InputArray=src, OutputArray=dst, jacobian=0)
|
||||
// https://docs.opencv.org/2.4/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#void%20Rodrigues(InputArray%20src,%20OutputArray%20dst,%20OutputArray%20jacobian)
|
||||
// vec to Mat, starting number is 3 long and each element is 1.
|
||||
cv.Rodrigues(rvec0, rMat0);
|
||||
|
||||
assert.ok(rMat0.data64F.length == 9);
|
||||
assert.ok(0.23 > rMat0.data64F[0] > 0.22);
|
||||
|
||||
// convert Mat to Vec, should be same as what we started with, 3 long and each item should be a 1.
|
||||
cv.Rodrigues(rMat0, rvec1);
|
||||
|
||||
assert.ok(rvec1.data64F.length == 3);
|
||||
assert.ok(1.01 > rvec1.data64F[0] > 0.9);
|
||||
// Answer should be around 1: 0.9999999999999999
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user