Merge pull request #15480 from cancerberoSgx:estimateAffine2D

js - cv.estimateAffine2D, cv.warpPolar
This commit is contained in:
Sebastián Gurin
2019-09-30 15:35:26 -03:00
committed by Alexander Alekhin
parent 5c9a624a85
commit a3144cbadc
3 changed files with 43 additions and 2 deletions

View File

@@ -65,3 +65,27 @@ QUnit.test('Rodrigues', function(assert) {
assert.ok(1.01 > rvec1.data64F[0] > 0.9);
// Answer should be around 1: 0.9999999999999999
});
QUnit.test('estimateAffine2D', function(assert) {
const inputs = cv.matFromArray(4, 1, cv.CV_32FC2, [
1, 1,
80, 0,
0, 80,
80, 80
]);
const outputs = cv.matFromArray(4, 1, cv.CV_32FC2, [
21, 51,
70, 77,
40, 40,
10, 70
]);
const M = cv.estimateAffine2D(inputs, outputs);
assert.ok(M instanceof cv.Mat);
assert.deepEqual(Array.from(M.data), [
23, 55, 97, 126, 87, 139, 227, 63, 0, 0,
0, 0, 0, 0, 232, 191, 71, 246, 12, 68,
165, 35, 53, 64, 99, 56, 27, 66, 14, 254,
212, 63, 103, 102, 102, 102, 102, 102, 182, 191,
195, 252, 174, 22, 55, 97, 73, 64
]);
});

View File

@@ -960,3 +960,20 @@ QUnit.test('test_filter', function(assert) {
src.delete();
}
});
QUnit.test('warpPolar', function(assert) {
const lines = new cv.Mat(255, 255, cv.CV_8U, new cv.Scalar(0));
for (let r = 0; r < lines.rows; r++) {
lines.row(r).setTo(new cv.Scalar(r));
}
cv.warpPolar(lines, lines, { width: 5, height: 5 }, new cv.Point(2, 2), 3,
cv.INTER_CUBIC | cv.WARP_FILL_OUTLIERS | cv.WARP_INVERSE_MAP);
assert.ok(lines instanceof cv.Mat);
assert.deepEqual(Array.from(lines.data), [
159, 172, 191, 210, 223,
146, 159, 191, 223, 236,
128, 128, 0, 0, 0,
109, 96, 64, 32, 19,
96, 83, 64, 45, 32
]);
});