mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
js: include LUT support
This commit is contained in:
parent
1a8d37d19e
commit
c319735d9b
41
modules/js/test/test_core.js
Normal file
41
modules/js/test/test_core.js
Normal file
@ -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…
Reference in New Issue
Block a user