Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions modules/js/test/test_core.js
Original file line number Diff line number Diff line change
@@ -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();
}
});
2 changes: 1 addition & 1 deletion modules/js/test/test_mat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions modules/js/test/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
},
Expand Down Expand Up @@ -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>
Expand Down
11 changes: 8 additions & 3 deletions modules/js/test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions platforms/js/opencv_js.config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'perspectiveTransform', 'polarToCart', 'pow', 'randn', 'randu', 'reduce', 'repeat', 'rotate', 'setIdentity', 'setRNGSeed',
'solve', 'solvePoly', 'split', 'sqrt', 'subtract', 'trace', 'transform', 'transpose', 'vconcat',
'setLogLevel', 'getLogLevel',
'LUT',
],
'Algorithm': [],
}
Expand Down