Merge pull request #24248 from opencv-pushbot:gitee/alalek/issue_22751

JavaScript: include LUT support
pull/24254/head^2
Alexander Smorkalov 1 year ago committed by GitHub
commit ee867ead1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      modules/js/test/test_core.js
  2. 2
      modules/js/test/test_mat.js
  3. 5
      modules/js/test/tests.html
  4. 11
      modules/js/test/tests.js
  5. 1
      platforms/js/opencv_js.config.py

@ -0,0 +1,41 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
if (typeof module !== 'undefined' && module.exports) {
// The environment is Node.js
var cv = require('./opencv.js'); // eslint-disable-line no-var
}
QUnit.module('Core', {});
QUnit.test('test_LUT', function(assert) {
// test LUT
{
let src = cv.matFromArray(3, 3, cv.CV_8UC1, [255, 128, 0, 0, 128, 255, 1, 2, 254]);
let lutTable = [];
for (let i = 0; i < 256; i++)
{
lutTable[i] = 255 - i;
}
let lut = cv.matFromArray(1, 256, cv.CV_8UC1, lutTable);
let dst = new cv.Mat();
cv.LUT(src, lut, dst);
//console.log(dst.data);
assert.equal(dst.ucharAt(0), 0);
assert.equal(dst.ucharAt(1), 127);
assert.equal(dst.ucharAt(2), 255);
assert.equal(dst.ucharAt(3), 255);
assert.equal(dst.ucharAt(4), 127);
assert.equal(dst.ucharAt(5), 0);
assert.equal(dst.ucharAt(6), 254);
assert.equal(dst.ucharAt(7), 253);
assert.equal(dst.ucharAt(8), 1);
src.delete();
lut.delete();
dst.delete();
}
});

@ -73,7 +73,7 @@ if (typeof module !== 'undefined' && module.exports) {
var cv = require('./opencv.js'); // eslint-disable-line no-var
}
QUnit.module('Core', {});
QUnit.module('CoreMat', {});
QUnit.test('test_mat_creation', function(assert) {
// Mat constructors.

@ -52,12 +52,12 @@
if (window.cv instanceof Promise) {
window.cv.then((target) => {
window.cv = target;
//console.log(cv.getBuildInformation());
console.log(cv.getBuildInformation());
QUnit.start();
})
} else {
// for backward compatible
// console.log(cv.getBuildInformation());
console.log(cv.getBuildInformation());
QUnit.start();
}
},
@ -108,6 +108,7 @@
<script type="application/javascript" async src="opencv.js" onerror="opencvjs_LoadError()"></script>
<script type="application/javascript" src="test_mat.js"></script>
<script type="application/javascript" src="test_utils.js"></script>
<script type="application/javascript" src="test_core.js"></script>
<script type="application/javascript" src="test_imgproc.js"></script>
<script type="application/javascript" src="test_objdetect.js"></script>
<script type="application/javascript" src="test_video.js"></script>

@ -44,10 +44,15 @@ testrunner.options.maxBlockDuration = 20000; // cause opencv_js.js need time to
testrunner.run(
{
code: 'opencv.js',
tests: ['test_mat.js', 'test_utils.js', 'test_imgproc.js',
'test_objdetect.js', 'test_video.js', 'test_features2d.js',
tests: ['test_mat.js',
'test_utils.js',
'test_core.js',
'test_imgproc.js',
'test_objdetect.js',
'test_video.js',
'test_features2d.js',
'test_photo.js',
'test_calib3d.js'
'test_calib3d.js',
],
},
function(err, report) {

@ -9,6 +9,7 @@ core = {
'perspectiveTransform', 'polarToCart', 'pow', 'randn', 'randu', 'reduce', 'repeat', 'rotate', 'setIdentity', 'setRNGSeed',
'solve', 'solvePoly', 'split', 'sqrt', 'subtract', 'trace', 'transform', 'transpose', 'vconcat',
'setLogLevel', 'getLogLevel',
'LUT',
],
'Algorithm': [],
}

Loading…
Cancel
Save