feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
35
3rdparty/opencv-4.5.4/modules/js/perf/README.md
vendored
Normal file
35
3rdparty/opencv-4.5.4/modules/js/perf/README.md
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# OpenCV.js Performance Test
|
||||
|
||||
## Node.js Version
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. node.js, npm: Make sure you have installed these beforehand with the system package manager.
|
||||
|
||||
2. Benchmark.js: Make sure you have installed Benchmark.js by npm before use. Please run `npm install` in the directory `<build_dir>/bin/perf`.
|
||||
|
||||
### How to Use
|
||||
|
||||
For example, if you want to test the performance of cvtColor, please run `perf_cvtcolor.js` by node in terminal:
|
||||
|
||||
```sh
|
||||
node perf_cvtcolor.js
|
||||
```
|
||||
|
||||
All tests of cvtColor will be run by above command.
|
||||
|
||||
If you just want to run one specific case, please use `--test_param_filter="()"` flag, like:
|
||||
|
||||
```sh
|
||||
node perf_cvtcolor.js --test_param_filter="(1920x1080, COLOR_BGR2GRAY)"
|
||||
```
|
||||
|
||||
## Browser Version
|
||||
|
||||
### How to Use
|
||||
|
||||
To run performance tests, please launch a local web server in <build_dir>/bin folder. For example, node http-server which serves on localhost:8080.
|
||||
|
||||
Navigate the web browser to the kernel page you want to test, like http://localhost:8080/perf/imgproc/cvtcolor.html.
|
||||
|
||||
You can input the parameter, and then click the `Run` button to run the specific case, or it will run all the cases.
|
38
3rdparty/opencv-4.5.4/modules/js/perf/base.js
vendored
Normal file
38
3rdparty/opencv-4.5.4/modules/js/perf/base.js
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
if (typeof window === 'undefined') {
|
||||
var cv = require("../opencv");
|
||||
if (cv instanceof Promise) {
|
||||
loadOpenCV();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
let gCvSize;
|
||||
|
||||
function getCvSize() {
|
||||
if (gCvSize === undefined) {
|
||||
gCvSize = {
|
||||
szODD: new cv.Size(127, 61),
|
||||
szQVGA: new cv.Size(320, 240),
|
||||
szVGA: new cv.Size(640, 480),
|
||||
szSVGA: new cv.Size(800, 600),
|
||||
szqHD: new cv.Size(960, 540),
|
||||
szXGA: new cv.Size(1024, 768),
|
||||
sz720p: new cv.Size(1280, 720),
|
||||
szSXGA: new cv.Size(1280, 1024),
|
||||
sz1080p: new cv.Size(1920, 1080),
|
||||
sz130x60: new cv.Size(130, 60),
|
||||
sz213x120: new cv.Size(120 * 1280 / 720, 120),
|
||||
};
|
||||
}
|
||||
|
||||
return gCvSize;
|
||||
}
|
||||
|
||||
async function loadOpenCV() {
|
||||
cv = await cv;
|
||||
}
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
exports.getCvSize = getCvSize;
|
||||
}
|
19
3rdparty/opencv-4.5.4/modules/js/perf/package.json
vendored
Normal file
19
3rdparty/opencv-4.5.4/modules/js/perf/package.json
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "opencv_js_perf",
|
||||
"description": "Perfermance tests for opencv js bindings",
|
||||
"version": "1.0.0",
|
||||
"dependencies" : {
|
||||
"benchmark" : "latest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/opencv/opencv.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "Apache 2.0 License",
|
||||
"bugs": {
|
||||
"url": "https://github.com/opencv/opencv/issues"
|
||||
},
|
||||
"homepage": "https://github.com/opencv/opencv"
|
||||
}
|
67
3rdparty/opencv-4.5.4/modules/js/perf/perf_64bits.html
vendored
Normal file
67
3rdparty/opencv-4.5.4/modules/js/perf/perf_64bits.html
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Functions for 64-bit Perf</h4>
|
||||
<h7>CountnonZero, Mat::dot, Split, Merge</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Mat Shape</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1000x1000)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../opencv.js" type="text/javascript"></script>
|
||||
<script src="./perf_64bits.js"></script>
|
||||
</body>
|
||||
</html>
|
180
3rdparty/opencv-4.5.4/modules/js/perf/perf_64bits.js
vendored
Normal file
180
3rdparty/opencv-4.5.4/modules/js/perf/perf_64bits.js
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
} else {
|
||||
runButton.removeAttribute('disabled');
|
||||
runButton.setAttribute('class', 'btn btn-primary');
|
||||
runButton.innerHTML = 'Run';
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
|
||||
function addCountNonZeroCase(suite) {
|
||||
suite.add('countNonZero', function() {
|
||||
cv.countNonZero(mat);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let mat = cv.Mat.eye(size[0], size[1], cv.CV_64F);
|
||||
}, 'teardown': function() {
|
||||
mat.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addMatDotCase(suite) {
|
||||
suite.add('Mat::dot', function() {
|
||||
mat.dot(matT);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let mat = cv.Mat.ones(size[0], size[1], cv.CV_64FC1);
|
||||
let matT = mat.t();
|
||||
}, 'teardown': function() {
|
||||
mat.delete();
|
||||
matT.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addSplitCase(suite) {
|
||||
suite.add('Split', function() {
|
||||
cv.split(mat, planes);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let mat = cv.Mat.ones(size[0], size[1], cv.CV_64FC3);
|
||||
let planes = new cv.MatVector();
|
||||
}, 'teardown': function() {
|
||||
mat.delete();
|
||||
planes.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addMergeCase(suite) {
|
||||
suite.add('Merge', function() {
|
||||
cv.merge(planes, mat);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let mat = new cv.Mat();
|
||||
let mat1 = cv.Mat.ones(size[0], size[1], cv.CV_64FC3);
|
||||
let planes = new cv.MatVector();
|
||||
cv.split(mat1, planes);
|
||||
}, 'teardown': function() {
|
||||
mat.delete();
|
||||
mat1.delete();
|
||||
planes.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setInitParams(suite, sizeArray) {
|
||||
for( let i =0; i < suite.length; i++) {
|
||||
suite[i].params = {
|
||||
size: sizeArray
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function log(message) {
|
||||
console.log(message);
|
||||
if (!isNodeJs) {
|
||||
logElement.innerHTML += `\n${'\t' + message}`;
|
||||
}
|
||||
}
|
||||
|
||||
function setBenchmarkSuite(suite) {
|
||||
suite
|
||||
// add listeners
|
||||
.on('cycle', function(event) {
|
||||
++currentCaseId;
|
||||
let size = event.target.params.size;
|
||||
log(`=== ${event.target.name} ${currentCaseId} ===`);
|
||||
log(`params: (${parseInt(size[0])}x${parseInt(size[1])})`);
|
||||
log('elapsed time:' +String(event.target.times.elapsed*1000)+' ms');
|
||||
log('mean time:' +String(event.target.stats.mean*1000)+' ms');
|
||||
log('stddev time:' +String(event.target.stats.deviation*1000)+' ms');
|
||||
log(String(event.target));
|
||||
})
|
||||
.on('error', function(event) { log(`test case ${event.target.name} failed`); })
|
||||
.on('complete', function(event) {
|
||||
log(`\n ###################################`)
|
||||
log(`Finished testing ${event.currentTarget.length} cases \n`);
|
||||
if (!isNodeJs) {
|
||||
runButton.removeAttribute('disabled');
|
||||
runButton.setAttribute('class', 'btn btn-primary');
|
||||
runButton.innerHTML = 'Run';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
var sizeArray;
|
||||
totalCaseNum = 4;
|
||||
currentCaseId = 0;
|
||||
if (/\([0-9]+x[0-9]+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+\)/g)[0];
|
||||
let sizeStrs = (params.match(/[0-9]+/g) || []).slice(0, 2).toString().split(",");
|
||||
sizeArray = sizeStrs.map(Number);
|
||||
} else {
|
||||
log("no getting invalid params, run all the cases with Mat of shape (1000 x 1000)");
|
||||
sizeArray = [1000, 1000];
|
||||
}
|
||||
addCountNonZeroCase(suite);
|
||||
addMatDotCase(suite);
|
||||
addSplitCase(suite);
|
||||
addMergeCase(suite);
|
||||
setInitParams(suite, sizeArray)
|
||||
setBenchmarkSuite(suite);
|
||||
log(`Running ${totalCaseNum} tests from 64-bit intrinsics`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
|
||||
// set test filter params
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
runButton.setAttribute("disabled", "disabled");
|
||||
runButton.setAttribute('class', 'btn btn-primary disabled');
|
||||
runButton.innerHTML = "Running";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
310
3rdparty/opencv-4.5.4/modules/js/perf/perf_helpfunc.js
vendored
Normal file
310
3rdparty/opencv-4.5.4/modules/js/perf/perf_helpfunc.js
vendored
Normal file
@ -0,0 +1,310 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if(isNodeJs) {
|
||||
var Base = require("./base");
|
||||
global.getCvSize = Base.getCvSize;
|
||||
}
|
||||
|
||||
var fillGradient = function(cv, img, delta=5) {
|
||||
let ch = img.channels();
|
||||
console.assert(!img.empty() && img.depth() == cv.CV_8U && ch <= 4);
|
||||
|
||||
let n = 255 / delta;
|
||||
for(let r = 0; r < img.rows; ++r) {
|
||||
let kR = r % (2*n);
|
||||
let valR = (kR<=n) ? delta*kR : delta*(2*n-kR);
|
||||
for(let c = 0; c < img.cols; ++c) {
|
||||
let kC = c % (2*n);
|
||||
let valC = (kC<=n) ? delta*kC : delta*(2*n-kC);
|
||||
let vals = [valR, valC, 200*r/img.rows, 255];
|
||||
let p = img.ptr(r, c);
|
||||
for(let i = 0; i < ch; ++i) p[i] = vals[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var smoothBorder = function(cv, img, color, delta=5) {
|
||||
let ch = img.channels();
|
||||
console.assert(!img.empty() && img.depth() == cv.CV_8U && ch <= 4);
|
||||
|
||||
let n = 100/delta;
|
||||
let nR = Math.min(n, (img.rows+1)/2);
|
||||
let nC = Math.min(n, (img.cols+1)/2);
|
||||
let s = new cv.Scalar();
|
||||
|
||||
for (let r = 0; r < nR; r++) {
|
||||
let k1 = r*delta/100.0, k2 = 1-k1;
|
||||
for(let c = 0; c < img.cols; c++) {
|
||||
let view = img.ptr(r, c);
|
||||
for(let i = 0; i < ch; i++) s[i] = view[i];
|
||||
for(let i = 0; i < ch; i++) view[i] = s[i]*k1 + color[i] * k2;
|
||||
}
|
||||
for(let c=0; c < img.cols; c++) {
|
||||
let view = img.ptr(img.rows-r-1, c);
|
||||
for(let i = 0; i < ch; i++) s[i] = view[i];
|
||||
for(let i = 0; i < ch; i++) view[i] = s[i]*k1 + color[i] * k2;
|
||||
}
|
||||
}
|
||||
for (let r = 0; r < img.rows; r++) {
|
||||
for(let c = 0; c < nC; c++) {
|
||||
let k1 = c*delta/100.0, k2 = 1-k1;
|
||||
let view = img.ptr(r, c);
|
||||
for(let i = 0; i < ch; i++) s[i] = view[i];
|
||||
for(let i = 0; i < ch; i++) view[i] = s[i]*k1 + color[i] * k2;
|
||||
}
|
||||
for(let c = 0; c < n; c++) {
|
||||
let k1 = c*delta/100.0, k2 = 1-k1;
|
||||
let view = img.ptr(r, img.cols-c-1);
|
||||
for(let i = 0; i < ch; i++) s[i] = view[i];
|
||||
for(let i = 0; i < ch; i++) view[i] = s[i]*k1 + color[i] * k2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var cvtStr2cvSize = function(strSize) {
|
||||
let size;
|
||||
let cvSize = getCvSize();
|
||||
|
||||
switch(strSize) {
|
||||
case "127,61": size = cvSize.szODD;break;
|
||||
case '320,240': size = cvSize.szQVGA;break;
|
||||
case '640,480': size = cvSize.szVGA;break;
|
||||
case '800,600': size = cvSize.szSVGA;break;
|
||||
case '960,540': size = cvSize.szqHD;break;
|
||||
case '1024,768': size = cvSize.szXGA;break;
|
||||
case '1280,720': size = cvSize.sz720p;break;
|
||||
case '1280,1024': size = cvSize.szSXGA;break;
|
||||
case '1920,1080': size = cvSize.sz1080p;break;
|
||||
case "130,60": size = cvSize.sz130x60;break;
|
||||
case '213,120': size = cvSize.sz213x120;break;
|
||||
default: console.error("unsupported size for this case");
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
var combine = function() {
|
||||
let result = [[]];
|
||||
for (let i = 0; i < arguments.length; ++i) {
|
||||
result = permute(result, arguments[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function permute (source, target) {
|
||||
let result = [];
|
||||
for (let i = 0; i < source.length; ++i) {
|
||||
for (let j = 0; j < target.length; ++j) {
|
||||
let tmp = source[i].slice();
|
||||
tmp.push(target[j]);
|
||||
result.push(tmp);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var constructMode = function (startStr, sChannel, dChannel) {
|
||||
let modeList = []
|
||||
for (let j in dChannel) {
|
||||
modeList.push(startStr+sChannel+"2"+dChannel[j])
|
||||
}
|
||||
return modeList;
|
||||
}
|
||||
|
||||
var enableButton = function () {
|
||||
runButton.removeAttribute('disabled');
|
||||
runButton.setAttribute('class', 'btn btn-primary');
|
||||
runButton.innerHTML = 'Run';
|
||||
}
|
||||
|
||||
var disableButton = function () {
|
||||
runButton.setAttribute("disabled", "disabled");
|
||||
runButton.setAttribute('class', 'btn btn-primary disabled');
|
||||
runButton.innerHTML = "Running";
|
||||
}
|
||||
|
||||
var log = function (message) {
|
||||
console.log(message);
|
||||
if (!isNodeJs) {
|
||||
logElement.innerHTML += `\n${'\t' + message}`;
|
||||
}
|
||||
}
|
||||
|
||||
var addKernelCase = function (suite, params, type, kernelFunc) {
|
||||
kernelFunc(suite, type);
|
||||
let index = suite.length - 1;
|
||||
suite[index].params = params;
|
||||
}
|
||||
|
||||
function constructParamLog(params, kernel) {
|
||||
let paramLog = '';
|
||||
if (kernel == "cvtcolor") {
|
||||
let mode = params.mode;
|
||||
let size = params.size;
|
||||
paramLog = `params: (${parseInt(size[0])}x${parseInt(size[1])}, ${mode})`;
|
||||
} else if (kernel == "resize") {
|
||||
let matType = params.matType;
|
||||
let size1 = params.from;
|
||||
let size2 = params.to;
|
||||
paramLog = `params: (${matType},${parseInt(size1.width)}x${parseInt(size1.height)},`+
|
||||
`${parseInt(size2.width)}x${parseInt(size2.height)})`;
|
||||
} else if (kernel == "threshold") {
|
||||
let matSize = params.matSize;
|
||||
let matType = params.matType;
|
||||
let threshType = params.threshType;
|
||||
paramLog = `params: (${parseInt(matSize.width)}x${parseInt(matSize.height)},`+
|
||||
`${matType},${threshType})`;
|
||||
} else if (kernel == "sobel") {
|
||||
let size = params.size;
|
||||
let ddepth = params.ddepth;
|
||||
let dxdy = params.dxdy;
|
||||
let ksize = params.ksize;
|
||||
let borderType = params.borderType;
|
||||
paramLog = `params: (${parseInt(size[0])}x${parseInt(size[1])},`+
|
||||
`${ddepth},${dxdy},${borderType}, ksize:${ksize})`;
|
||||
} else if (kernel == "filter2d") {
|
||||
let size = params.size;
|
||||
let ksize = params.ksize;
|
||||
let borderMode = params.borderMode;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${ksize},${borderMode})`;
|
||||
} else if (kernel == "scharr") {
|
||||
let size = params.size;
|
||||
let ddepth = params.ddepth;
|
||||
let dxdy = params.dxdy;
|
||||
let borderType = params.borderType;
|
||||
paramLog = `params: (${parseInt(size[0])}x${parseInt(size[1])},`+
|
||||
`${ddepth},${dxdy},${borderType})`;
|
||||
} else if (kernel == "gaussianBlur" || kernel == "blur") {
|
||||
let size = params.size;
|
||||
let matType = params.matType;
|
||||
let borderType = params.borderType;
|
||||
let ksize = params.ksize;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${matType},${borderType}, ksize: (${ksize}x${ksize}))`;
|
||||
} else if (kernel == "medianBlur") {
|
||||
let size = params.size;
|
||||
let matType = params.matType;
|
||||
let ksize = params.ksize;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${matType}, ksize: ${ksize})`;
|
||||
} else if (kernel == "erode" || kernel == "dilate" || kernel == "pyrDown") {
|
||||
let size = params.size;
|
||||
let matType = params.matType;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${matType})`;
|
||||
} else if (kernel == "remap") {
|
||||
let size = params.size;
|
||||
let matType = params.matType;
|
||||
let mapType = params.mapType;
|
||||
let interType = params.interType;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${matType}, ${mapType}, ${interType})`;
|
||||
} else if (kernel == "warpAffine" || kernel == "warpPerspective") {
|
||||
let size = params.size;
|
||||
let interType = params.interType;
|
||||
let borderMode = params.borderMode;
|
||||
paramLog = `params: (${parseInt(size.width)}x${parseInt(size.height)},`+
|
||||
`${interType}, ${borderMode})`;
|
||||
}
|
||||
return paramLog;
|
||||
}
|
||||
|
||||
var setBenchmarkSuite = function (suite, kernel, currentCaseId) {
|
||||
suite
|
||||
// add listeners
|
||||
.on('cycle', function(event) {
|
||||
++currentCaseId;
|
||||
let params = event.target.params;
|
||||
paramLog = constructParamLog(params, kernel);
|
||||
|
||||
log(`=== ${event.target.name} ${currentCaseId} ===`);
|
||||
log(paramLog);
|
||||
log('elapsed time:' +String(event.target.times.elapsed*1000)+' ms');
|
||||
log('mean time:' +String(event.target.stats.mean*1000)+' ms');
|
||||
log('stddev time:' +String(event.target.stats.deviation*1000)+' ms');
|
||||
log(String(event.target));
|
||||
})
|
||||
.on('error', function(event) { log(`test case ${event.target.name} failed`); })
|
||||
.on('complete', function(event) {
|
||||
log(`\n ###################################`)
|
||||
log(`Finished testing ${event.currentTarget.length} cases \n`);
|
||||
if (!isNodeJs) {
|
||||
runButton.removeAttribute('disabled');
|
||||
runButton.setAttribute('class', 'btn btn-primary');
|
||||
runButton.innerHTML = 'Run';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var decodeParams2Case = function(paramContent, paramsList, combinations) {
|
||||
let sizeString = (paramContent.match(/[0-9]+x[0-9]+/g) || []).toString();
|
||||
let sizes = (sizeString.match(/[0-9]+/g) || []);
|
||||
let paramSize = paramsList.length;
|
||||
let paramObjs = []
|
||||
let sizeCount = 0;
|
||||
for (let i = 0; i < paramSize; i++) {
|
||||
let param = paramsList[i];
|
||||
let paramName = param.name;
|
||||
let paramValue = param.value;
|
||||
let paramReg = param.reg;
|
||||
let paramIndex = param.index;
|
||||
|
||||
if(paramValue != "") {
|
||||
paramObjs.push({name: paramName, value: paramValue, index: paramIndex});
|
||||
} else if (paramName.startsWith('size')) {
|
||||
let sizeStr = sizes.slice(sizeCount, sizeCount+2).toString();
|
||||
paramValue = cvtStr2cvSize(sizeStr);
|
||||
sizeCount += 2;
|
||||
paramObjs.push({name: paramName, value: paramValue, index: paramIndex});
|
||||
} else {
|
||||
for (let index in paramReg) {
|
||||
let reg = eval(paramReg[index]);
|
||||
if ('loc' in param) {
|
||||
paramValue = (paramContent.match(reg) || [])[param.loc].toString();
|
||||
} else {
|
||||
paramValue = (paramContent.match(reg) || []).toString();
|
||||
}
|
||||
|
||||
if (paramValue != "") {
|
||||
paramObjs.push({name: paramName, value: paramValue, index: paramIndex});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let location = [];
|
||||
for (let i = 0; i < combinations.length; ++i) {
|
||||
let combination = combinations[i];
|
||||
for (let j = 0; j < combination.length; ++j) {
|
||||
if (judgeCombin(combination[j], paramObjs)) {
|
||||
location.push([i,j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
function judgeCombin(combination, paramObjs) {
|
||||
for (let i =0; i < paramObjs.length; i++) {
|
||||
if (paramObjs[i].value != combination[paramObjs[i].index]){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
exports.enableButton = enableButton;
|
||||
exports.disableButton = disableButton;
|
||||
exports.fillGradient = fillGradient;
|
||||
exports.smoothBorder = smoothBorder;
|
||||
exports.cvtStr2cvSize = cvtStr2cvSize;
|
||||
exports.combine = combine;
|
||||
exports.constructMode = constructMode;
|
||||
exports.log = log;
|
||||
exports.decodeParams2Case = decodeParams2Case;
|
||||
exports.setBenchmarkSuite = setBenchmarkSuite;
|
||||
exports.addKernelCase = addKernelCase;
|
||||
}
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_blur.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_blur.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Blur</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1280x720, CV_8UC1, BORDER_REPLICATE)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_blur.js"></script>
|
||||
</body>
|
||||
</html>
|
133
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_blur.js
vendored
Normal file
133
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_blur.js
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const BlurSize = [cvSize.szODD, cvSize.szQVGA, cvSize.szVGA, cvSize.sz720p];
|
||||
const Blur5x16Size = [cvSize.szVGA, cvSize.sz720p];
|
||||
const BlurType = ["CV_8UC1", "CV_8UC4", "CV_16UC1", "CV_16SC1", "CV_32FC1"];
|
||||
const BlurType5x5 = ["CV_8UC1", "CV_8UC4", "CV_16UC1", "CV_16SC1", "CV_32FC1", "CV_32FC3"];
|
||||
const BorderType3x3 = ["BORDER_REPLICATE", "BORDER_CONSTANT"];
|
||||
const BorderTypeAll = ["BORDER_REPLICATE", "BORDER_CONSTANT", "BORDER_REFLECT", "BORDER_REFLECT101"];
|
||||
|
||||
const combiBlur3x3 = combine(BlurSize, BlurType, BorderType3x3);
|
||||
const combiBlur16x16 = combine(Blur5x16Size, BlurType, BorderTypeAll);
|
||||
const combiBlur5x5 = combine(Blur5x16Size, BlurType5x5, BorderTypeAll);
|
||||
|
||||
function addBlurCase(suite, type) {
|
||||
suite.add('blur', function() {
|
||||
cv.blur(src, dst, ksize, new cv.Point(-1,-1), borderType);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let borderType = cv[this.params.borderType];
|
||||
let ksizeNum = this.params.ksize;
|
||||
let ksize = new cv.Size(ksizeNum, ksizeNum);
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addBlurModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
let borderType = combination[i][2];
|
||||
let ksizeArray = [3, 16, 5];
|
||||
|
||||
let params = {size: size, matType:matType, ksize: ksizeArray[type], borderType:borderType};
|
||||
addKernelCase(suite, params, type, addBlurCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
paramObjs.push({name:"borderMode", value: "", reg:["/BORDER\_\\w+/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs,blurCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addBlurModeCase(suite, [blurCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addBlurModeCase(suite, combiBlur3x3, 0);
|
||||
addBlurModeCase(suite, combiBlur16x16, 1);
|
||||
addBlurModeCase(suite, combiBlur5x5, 2);
|
||||
}
|
||||
setBenchmarkSuite(suite, "blur", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from blur`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let blurCombinations = [combiBlur3x3, combiBlur16x16, combiBlur5x5];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_cvtcolor.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_cvtcolor.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>CvtColor</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480,COLOR_RGBA2GRAY)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_cvtcolor.js"></script>
|
||||
</body>
|
||||
</html>
|
414
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_cvtcolor.js
vendored
Normal file
414
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_cvtcolor.js
vendored
Normal file
@ -0,0 +1,414 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.constructMode = HelpFunc.constructMode;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
// extra color conversions supported implicitly
|
||||
{
|
||||
cv.CX_BGRA2HLS = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2HLS,
|
||||
cv.CX_BGRA2HLS_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2HLS_FULL,
|
||||
cv.CX_BGRA2HSV = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2HSV,
|
||||
cv.CX_BGRA2HSV_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2HSV_FULL,
|
||||
cv.CX_BGRA2Lab = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2Lab,
|
||||
cv.CX_BGRA2Luv = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2Luv,
|
||||
cv.CX_BGRA2XYZ = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2XYZ,
|
||||
cv.CX_BGRA2YCrCb = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2YCrCb,
|
||||
cv.CX_BGRA2YUV = cv.COLOR_COLORCVT_MAX + cv.COLOR_BGR2YUV,
|
||||
cv.CX_HLS2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_HLS2BGR,
|
||||
cv.CX_HLS2BGRA_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_HLS2BGR_FULL,
|
||||
cv.CX_HLS2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_HLS2RGB,
|
||||
cv.CX_HLS2RGBA_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_HLS2RGB_FULL,
|
||||
cv.CX_HSV2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_HSV2BGR,
|
||||
cv.CX_HSV2BGRA_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_HSV2BGR_FULL,
|
||||
cv.CX_HSV2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_HSV2RGB,
|
||||
cv.CX_HSV2RGBA_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_HSV2RGB_FULL,
|
||||
cv.CX_Lab2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Lab2BGR,
|
||||
cv.CX_Lab2LBGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Lab2LBGR,
|
||||
cv.CX_Lab2LRGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Lab2LRGB,
|
||||
cv.CX_Lab2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Lab2RGB,
|
||||
cv.CX_LBGRA2Lab = cv.COLOR_COLORCVT_MAX + cv.COLOR_LBGR2Lab,
|
||||
cv.CX_LBGRA2Luv = cv.COLOR_COLORCVT_MAX + cv.COLOR_LBGR2Luv,
|
||||
cv.CX_LRGBA2Lab = cv.COLOR_COLORCVT_MAX + cv.COLOR_LRGB2Lab,
|
||||
cv.CX_LRGBA2Luv = cv.COLOR_COLORCVT_MAX + cv.COLOR_LRGB2Luv,
|
||||
cv.CX_Luv2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Luv2BGR,
|
||||
cv.CX_Luv2LBGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Luv2LBGR,
|
||||
cv.CX_Luv2LRGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Luv2LRGB,
|
||||
cv.CX_Luv2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_Luv2RGB,
|
||||
cv.CX_RGBA2HLS = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2HLS,
|
||||
cv.CX_RGBA2HLS_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2HLS_FULL,
|
||||
cv.CX_RGBA2HSV = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2HSV,
|
||||
cv.CX_RGBA2HSV_FULL = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2HSV_FULL,
|
||||
cv.CX_RGBA2Lab = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2Lab,
|
||||
cv.CX_RGBA2Luv = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2Luv,
|
||||
cv.CX_RGBA2XYZ = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2XYZ,
|
||||
cv.CX_RGBA2YCrCb = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2YCrCb,
|
||||
cv.CX_RGBA2YUV = cv.COLOR_COLORCVT_MAX + cv.COLOR_RGB2YUV,
|
||||
cv.CX_XYZ2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_XYZ2BGR,
|
||||
cv.CX_XYZ2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_XYZ2RGB,
|
||||
cv.CX_YCrCb2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_YCrCb2BGR,
|
||||
cv.CX_YCrCb2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_YCrCb2RGB,
|
||||
cv.CX_YUV2BGRA = cv.COLOR_COLORCVT_MAX + cv.COLOR_YUV2BGR,
|
||||
cv.CX_YUV2RGBA = cv.COLOR_COLORCVT_MAX + cv.COLOR_YUV2RGB
|
||||
};
|
||||
|
||||
// didn't support 16u and 32f perf tests according to
|
||||
// https://github.com/opencv/opencv/commit/4e679e1cc5b075ec006b29a58b4fe117523fba1d
|
||||
function constructCvtMode16U() {
|
||||
let cvtMode16U = [];
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "BGR", ["BGRA", "GRAY", "RGB", "RGBA", "XYZ", "YCrCb", "YUV"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "BGRA", ["BGR", "GRAY", "RGBA"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("CX_", "BGRA", ["XYZ", "YCrCb", "YUV"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "GRAY", ["BGR", "BGRA"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "RGB", ["GRAY", "XYZ", "YCrCb", "YUV"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "RGBA", ["BGR", "GRAY"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("CX_", "RGBA", ["XYZ", "YCrCb", "YUV"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "XYZ", ["BGR", "RGB"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("CX_", "XYZ", ["BGRA", "RGBA"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "YCrCb", ["BGR", "RGB"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("CX_", "YCrCb", ["BGRA", "RGBA"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("COLOR_", "YUV", ["BGR", "RGB"]));
|
||||
cvtMode16U = cvtMode16U.concat(constructMode("CX_", "YUV", ["BGRA", "RGBA"]));
|
||||
|
||||
return cvtMode16U;
|
||||
}
|
||||
|
||||
const CvtMode16U = constructCvtMode16U();
|
||||
|
||||
const CvtMode16USize = [cvSize.szODD, cvSize.szVGA, cvSize.sz1080p];
|
||||
const combiCvtMode16U = combine(CvtMode16USize, CvtMode16U);
|
||||
|
||||
function constructCvtMode32F(source) {
|
||||
let cvtMode32F = source;
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "BGR", ["HLS", "HLS_FULL", "HSV", "HSV_FULL", "Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "BGRA", ["HLS", "HLS_FULL", "HSV", "HSV_FULL", "Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "HLS", ["BGR", "BGR_FULL", "RGB", "RGB_FULL"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "HLS", ["BGRA", "BGRA_FULL", "RGBA", "RGBA_FULL"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "HSV", ["BGR", "BGR_FULL", "RGB", "RGB_FULL"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "HSV", ["BGRA", "BGRA_FULL", "RGBA", "RGBA_FULL"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "Lab", ["BGR", "LBGR", "RGB", "LRGB"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "Lab", ["BGRA", "LBGRA", "RGBA", "LRGBA"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "Luv", ["BGR", "LBGR", "RGB", "LRGB"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "Luv", ["BGRA", "LBGRA", "RGBA", "LRGBA"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "LBGR", ["Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "LBGRA", ["Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "LRGB", ["Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "LRGBA", ["Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("COLOR_", "RGB", ["HLS", "HLS_FULL", "HSV", "HSV_FULL", "Lab", "Luv"]));
|
||||
cvtMode32F = cvtMode32F.concat(constructMode("CX_", "RGBA", ["HLS", "HLS_FULL", "HSV", "HSV_FULL", "Lab", "Luv"]));
|
||||
|
||||
return cvtMode32F;
|
||||
}
|
||||
|
||||
const CvtMode32F = constructCvtMode32F(CvtMode16U);
|
||||
|
||||
const CvtMode32FSize = [cvSize.szODD, cvSize.szVGA, cvSize.sz1080p];
|
||||
const combiCvtMode32F = combine(CvtMode32FSize, CvtMode32F);
|
||||
|
||||
function constructeCvtMode(source) {
|
||||
let cvtMode = source
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "BGR", ["BGR555", "BGR565"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "BGR555", ["BGR", "BGRA", "GRAY", "RGB", "RGBA"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "BGR565", ["BGR", "BGRA", "GRAY", "RGB", "RGBA"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "BGRA", ["BGR555", "BGR565"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "GRAY", ["BGR555", "BGR565"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "RGB", ["BGR555", "BGR565"]));
|
||||
cvtMode = cvtMode.concat(constructMode("COLOR_", "RGBA", ["BGR555", "BGR565"]));
|
||||
|
||||
return cvtMode;
|
||||
}
|
||||
|
||||
const CvtMode = constructeCvtMode(CvtMode32F);
|
||||
|
||||
const CvtModeSize = [cvSize.szODD, cvSize.szVGA, cvSize.sz1080p];
|
||||
// combiCvtMode permute size and mode
|
||||
const combiCvtMode = combine(CvtModeSize, CvtMode);
|
||||
|
||||
const CvtModeBayer = [
|
||||
"COLOR_BayerBG2BGR", "COLOR_BayerBG2BGRA", "COLOR_BayerBG2BGR_VNG", "COLOR_BayerBG2GRAY",
|
||||
"COLOR_BayerGB2BGR", "COLOR_BayerGB2BGRA", "COLOR_BayerGB2BGR_VNG", "COLOR_BayerGB2GRAY",
|
||||
"COLOR_BayerGR2BGR", "COLOR_BayerGR2BGRA", "COLOR_BayerGR2BGR_VNG", "COLOR_BayerGR2GRAY",
|
||||
"COLOR_BayerRG2BGR", "COLOR_BayerRG2BGRA", "COLOR_BayerRG2BGR_VNG", "COLOR_BayerRG2GRAY"
|
||||
];
|
||||
const CvtModeBayerSize = [cvSize.szODD, cvSize.szVGA];
|
||||
const combiCvtModeBayer = combine(CvtModeBayerSize, CvtModeBayer);
|
||||
|
||||
|
||||
const CvtMode2 = [
|
||||
"COLOR_YUV2BGR_NV12", "COLOR_YUV2BGRA_NV12", "COLOR_YUV2RGB_NV12", "COLOR_YUV2RGBA_NV12", "COLOR_YUV2BGR_NV21", "COLOR_YUV2BGRA_NV21", "COLOR_YUV2RGB_NV21", "COLOR_YUV2RGBA_NV21",
|
||||
"COLOR_YUV2BGR_YV12", "COLOR_YUV2BGRA_YV12", "COLOR_YUV2RGB_YV12", "COLOR_YUV2RGBA_YV12", "COLOR_YUV2BGR_IYUV", "COLOR_YUV2BGRA_IYUV", "COLOR_YUV2RGB_IYUV", "COLOR_YUV2RGBA_IYUV",
|
||||
"COLOR_YUV2GRAY_420", "COLOR_YUV2RGB_UYVY", "COLOR_YUV2BGR_UYVY", "COLOR_YUV2RGBA_UYVY", "COLOR_YUV2BGRA_UYVY", "COLOR_YUV2RGB_YUY2", "COLOR_YUV2BGR_YUY2", "COLOR_YUV2RGB_YVYU",
|
||||
"COLOR_YUV2BGR_YVYU", "COLOR_YUV2RGBA_YUY2", "COLOR_YUV2BGRA_YUY2", "COLOR_YUV2RGBA_YVYU", "COLOR_YUV2BGRA_YVYU"
|
||||
];
|
||||
const CvtMode2Size = [cvSize.szVGA, cvSize.sz1080p, cvSize.sz130x60];
|
||||
const combiCvtMode2 = combine(CvtMode2Size, CvtMode2);
|
||||
|
||||
const CvtMode3 = [
|
||||
"COLOR_RGB2YUV_IYUV", "COLOR_BGR2YUV_IYUV", "COLOR_RGBA2YUV_IYUV", "COLOR_BGRA2YUV_IYUV",
|
||||
"COLOR_RGB2YUV_YV12", "COLOR_BGR2YUV_YV12", "COLOR_RGBA2YUV_YV12", "COLOR_BGRA2YUV_YV12"
|
||||
];
|
||||
const CvtMode3Size = [cvSize.szVGA, cvSize.sz720p, cvSize.sz1080p, cvSize.sz130x60];
|
||||
const combiCvtMode3 = combine(CvtMode3Size, CvtMode3);
|
||||
|
||||
const EdgeAwareBayerMode = [
|
||||
"COLOR_BayerBG2BGR_EA", "COLOR_BayerGB2BGR_EA", "COLOR_BayerRG2BGR_EA", "COLOR_BayerGR2BGR_EA"
|
||||
];
|
||||
const EdgeAwareBayerModeSize = [cvSize.szVGA, cvSize.sz720p, cvSize.sz1080p, cvSize.sz130x60];
|
||||
const combiEdgeAwareBayer = combine(EdgeAwareBayerModeSize, EdgeAwareBayerMode);
|
||||
|
||||
// This function returns an array. The 1st element is the channel number of
|
||||
// source mat and 2nd element is the channel number of destination mat.
|
||||
function getConversionInfo(cvtMode) {
|
||||
switch(cvtMode) {
|
||||
case "COLOR_BayerBG2GRAY": case "COLOR_BayerGB2GRAY":
|
||||
case "COLOR_BayerGR2GRAY": case "COLOR_BayerRG2GRAY":
|
||||
case "COLOR_YUV2GRAY_420":
|
||||
return [1, 1];
|
||||
case "COLOR_GRAY2BGR555": case "COLOR_GRAY2BGR565":
|
||||
return [1, 2];
|
||||
case "COLOR_BayerBG2BGR": case "COLOR_BayerBG2BGR_VNG":
|
||||
case "COLOR_BayerGB2BGR": case "COLOR_BayerGB2BGR_VNG":
|
||||
case "COLOR_BayerGR2BGR": case "COLOR_BayerGR2BGR_VNG":
|
||||
case "COLOR_BayerRG2BGR": case "COLOR_BayerRG2BGR_VNG":
|
||||
case "COLOR_GRAY2BGR":
|
||||
case "COLOR_YUV2BGR_NV12": case "COLOR_YUV2RGB_NV12":
|
||||
case "COLOR_YUV2BGR_NV21": case "COLOR_YUV2RGB_NV21":
|
||||
case "COLOR_YUV2BGR_YV12": case "COLOR_YUV2RGB_YV12":
|
||||
case "COLOR_YUV2BGR_IYUV": case "COLOR_YUV2RGB_IYUV":
|
||||
return [1, 3];
|
||||
case "COLOR_GRAY2BGRA":
|
||||
case "COLOR_YUV2BGRA_NV12": case "COLOR_YUV2RGBA_NV12":
|
||||
case "COLOR_YUV2BGRA_NV21": case "COLOR_YUV2RGBA_NV21":
|
||||
case "COLOR_YUV2BGRA_YV12": case "COLOR_YUV2RGBA_YV12":
|
||||
case "COLOR_YUV2BGRA_IYUV": case "COLOR_YUV2RGBA_IYUV":
|
||||
case "COLOR_BayerBG2BGRA": case "COLOR_BayerGB2BGRA":
|
||||
case "COLOR_BayerGR2BGRA": case "COLOR_BayerRG2BGRA":
|
||||
return [1, 4];
|
||||
case "COLOR_BGR5552GRAY": case "COLOR_BGR5652GRAY":
|
||||
return [2, 1];
|
||||
case "COLOR_BGR5552BGR": case "COLOR_BGR5552RGB":
|
||||
case "COLOR_BGR5652BGR": case "COLOR_BGR5652RGB":
|
||||
case "COLOR_YUV2RGB_UYVY": case "COLOR_YUV2BGR_UYVY":
|
||||
case "COLOR_YUV2RGB_YUY2": case "COLOR_YUV2BGR_YUY2":
|
||||
case "COLOR_YUV2RGB_YVYU": case "COLOR_YUV2BGR_YVYU":
|
||||
return [2, 3];
|
||||
case "COLOR_BGR5552BGRA": case "COLOR_BGR5552RGBA":
|
||||
case "COLOR_BGR5652BGRA": case "COLOR_BGR5652RGBA":
|
||||
case "COLOR_YUV2RGBA_UYVY": case "COLOR_YUV2BGRA_UYVY":
|
||||
case "COLOR_YUV2RGBA_YUY2": case "COLOR_YUV2BGRA_YUY2":
|
||||
case "COLOR_YUV2RGBA_YVYU": case "COLOR_YUV2BGRA_YVYU":
|
||||
return [2, 4];
|
||||
case "COLOR_BGR2GRAY": case "COLOR_RGB2GRAY":
|
||||
case "COLOR_RGB2YUV_IYUV": case "COLOR_RGB2YUV_YV12":
|
||||
case "COLOR_BGR2YUV_IYUV": case "COLOR_BGR2YUV_YV12":
|
||||
return [3, 1];
|
||||
case "COLOR_BGR2BGR555": case "COLOR_BGR2BGR565":
|
||||
case "COLOR_RGB2BGR555": case "COLOR_RGB2BGR565":
|
||||
return [3, 2];
|
||||
case "COLOR_BGR2HLS": case "COLOR_BGR2HLS_FULL":
|
||||
case "COLOR_BGR2HSV": case "COLOR_BGR2HSV_FULL":
|
||||
case "COLOR_BGR2Lab": case "COLOR_BGR2Luv":
|
||||
case "COLOR_BGR2RGB": case "COLOR_BGR2XYZ":
|
||||
case "COLOR_BGR2YCrCb": case "COLOR_BGR2YUV":
|
||||
case "COLOR_HLS2BGR": case "COLOR_HLS2BGR_FULL":
|
||||
case "COLOR_HLS2RGB": case "COLOR_HLS2RGB_FULL":
|
||||
case "COLOR_HSV2BGR": case "COLOR_HSV2BGR_FULL":
|
||||
case "COLOR_HSV2RGB": case "COLOR_HSV2RGB_FULL":
|
||||
case "COLOR_Lab2BGR": case "COLOR_Lab2LBGR":
|
||||
case "COLOR_Lab2LRGB": case "COLOR_Lab2RGB":
|
||||
case "COLOR_LBGR2Lab": case "COLOR_LBGR2Luv":
|
||||
case "COLOR_LRGB2Lab": case "COLOR_LRGB2Luv":
|
||||
case "COLOR_Luv2BGR": case "COLOR_Luv2LBGR":
|
||||
case "COLOR_Luv2LRGB": case "COLOR_Luv2RGB":
|
||||
case "COLOR_RGB2HLS": case "COLOR_RGB2HLS_FULL":
|
||||
case "COLOR_RGB2HSV": case "COLOR_RGB2HSV_FULL":
|
||||
case "COLOR_RGB2Lab": case "COLOR_RGB2Luv":
|
||||
case "COLOR_RGB2XYZ": case "COLOR_RGB2YCrCb":
|
||||
case "COLOR_RGB2YUV": case "COLOR_XYZ2BGR":
|
||||
case "COLOR_XYZ2RGB": case "COLOR_YCrCb2BGR":
|
||||
case "COLOR_YCrCb2RGB": case "COLOR_YUV2BGR":
|
||||
case "COLOR_YUV2RGB":
|
||||
return [3, 3];
|
||||
case "COLOR_BGR2BGRA": case "COLOR_BGR2RGBA":
|
||||
case "CX_HLS2BGRA": case "CX_HLS2BGRA_FULL":
|
||||
case "CX_HLS2RGBA": case "CX_HLS2RGBA_FULL":
|
||||
case "CX_HSV2BGRA": case "CX_HSV2BGRA_FULL":
|
||||
case "CX_HSV2RGBA": case "CX_HSV2RGBA_FULL":
|
||||
case "CX_Lab2BGRA": case "CX_Lab2LBGRA":
|
||||
case "CX_Lab2LRGBA": case "CX_Lab2RGBA":
|
||||
case "CX_Luv2BGRA": case "CX_Luv2LBGRA":
|
||||
case "CX_Luv2LRGBA": case "CX_Luv2RGBA":
|
||||
case "CX_XYZ2BGRA": case "CX_XYZ2RGBA":
|
||||
case "CX_YCrCb2BGRA": case "CX_YCrCb2RGBA":
|
||||
case "CX_YUV2BGRA": case "CX_YUV2RGBA":
|
||||
return [3, 4];
|
||||
case "COLOR_BGRA2GRAY": case "COLOR_RGBA2GRAY":
|
||||
case "COLOR_RGBA2YUV_IYUV": case "COLOR_RGBA2YUV_YV12":
|
||||
case "COLOR_BGRA2YUV_IYUV": case "COLOR_BGRA2YUV_YV12":
|
||||
return [4, 1];
|
||||
case "COLOR_BGRA2BGR555": case "COLOR_BGRA2BGR565":
|
||||
case "COLOR_RGBA2BGR555": case "COLOR_RGBA2BGR565":
|
||||
return [4, 2];
|
||||
case "COLOR_BGRA2BGR": case "CX_BGRA2HLS":
|
||||
case "CX_BGRA2HLS_FULL": case "CX_BGRA2HSV":
|
||||
case "CX_BGRA2HSV_FULL": case "CX_BGRA2Lab":
|
||||
case "CX_BGRA2Luv": case "CX_BGRA2XYZ":
|
||||
case "CX_BGRA2YCrCb": case "CX_BGRA2YUV":
|
||||
case "CX_LBGRA2Lab": case "CX_LBGRA2Luv":
|
||||
case "CX_LRGBA2Lab": case "CX_LRGBA2Luv":
|
||||
case "COLOR_RGBA2BGR": case "CX_RGBA2HLS":
|
||||
case "CX_RGBA2HLS_FULL": case "CX_RGBA2HSV":
|
||||
case "CX_RGBA2HSV_FULL": case "CX_RGBA2Lab":
|
||||
case "CX_RGBA2Luv": case "CX_RGBA2XYZ":
|
||||
case "CX_RGBA2YCrCb": case "CX_RGBA2YUV":
|
||||
return [4, 3];
|
||||
case "COLOR_BGRA2RGBA":
|
||||
return [4, 4];
|
||||
default:
|
||||
console.error("Unknown conversion type");
|
||||
break;
|
||||
};
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
function getMatType(chPair) {
|
||||
let dataType = "8U"; // now just support "8U" data type, we can set it as a param to extend the data type later.
|
||||
let mat1Type, mat2Type;
|
||||
if (chPair[0] === 0) {
|
||||
mat1Type = `CV_${dataType}C`;
|
||||
} else {
|
||||
mat1Type = `CV_${dataType}C${chPair[0].toString()}`;
|
||||
}
|
||||
if (chPair[1] === 0) {
|
||||
mat2Type = `CV_${dataType}C`;
|
||||
} else {
|
||||
mat2Type = `CV_${dataType}C${chPair[1].toString()}`;
|
||||
}
|
||||
return [mat1Type, mat2Type];
|
||||
}
|
||||
|
||||
function addCvtColorCase(suite, type) {
|
||||
suite.add('cvtColor', function() {
|
||||
cv.cvtColor(mat1, mat2, mode, 0);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = this.params.matType;
|
||||
let mode = cv[this.params.mode]%cv.COLOR_COLORCVT_MAX;
|
||||
let mat1 = new cv.Mat(size[1], size[0], cv[matType[0]]);
|
||||
let mat2 = new cv.Mat(size[1], size[0], cv[matType[1]]);
|
||||
},
|
||||
'teardown': function() {
|
||||
mat1.delete();
|
||||
mat2.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addCvtModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for(let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let mode = combination[i][1];
|
||||
let chPair = getConversionInfo(mode);
|
||||
let matType = getMatType(chPair);
|
||||
let sizeArray;
|
||||
if (type == 0) {
|
||||
sizeArray = [size.width, size.height];
|
||||
} else {
|
||||
sizeArray = [size.width, size.height+size.height/2];
|
||||
}
|
||||
let params = {size:sizeArray, matType: matType, mode: mode};
|
||||
addKernelCase(suite, params, type, addCvtColorCase);
|
||||
};
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"mode", value:"", reg:["/CX\_[A-z]+2[A-z]+/", "/COLOR\_[A-z]+2[A-z]+/"], index:1});
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
|
||||
let locationList = decodeParams2Case(params, paramObjs,combinations);
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
if (first < 2) {
|
||||
addCvtModeCase(suite, [combinations[first][second]], 0);
|
||||
} else {
|
||||
addCvtModeCase(suite, [combinations[first][second]], 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addCvtModeCase(suite, combiCvtMode, 0);
|
||||
addCvtModeCase(suite, combiCvtModeBayer, 0);
|
||||
addCvtModeCase(suite, combiCvtMode2, 1);
|
||||
addCvtModeCase(suite, combiCvtMode3, 1);
|
||||
}
|
||||
setBenchmarkSuite(suite, "cvtcolor", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from CvtColor`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
// init
|
||||
let combinations = [combiCvtMode, combiCvtModeBayer, combiCvtMode2, combiCvtMode3];//, combiEdgeAwareBayer];
|
||||
|
||||
// set test filter params
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_dilate.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_dilate.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Dilate</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1024x768, CV_8UC1)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_dilate.js"></script>
|
||||
</body>
|
||||
</html>
|
120
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_dilate.js
vendored
Normal file
120
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_dilate.js
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const DilateSize = [cvSize.szQVGA, cvSize.szVGA, cvSize.szSVGA, cvSize.szXGA, cvSize.szSXGA];
|
||||
const DilateType = ["CV_8UC1", "CV_8UC4"];
|
||||
const combiDilate = combine(DilateSize, DilateType);
|
||||
|
||||
function addDialteCase(suite, type) {
|
||||
suite.add('dilate', function() {
|
||||
cv.dilate(src, dst, kernel);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
let kernel = new cv.Mat();
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
kernel.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addDilateModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
|
||||
let params = {size: size, matType:matType};
|
||||
addKernelCase(suite, params, type, addDialteCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
let locationList = decodeParams2Case(params, paramObjs, dilateCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addDilateModeCase(suite, [dilateCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addDilateModeCase(suite, combiDilate, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "dilate", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from dilate`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let dilateCombinations = [combiDilate];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_erode.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_erode.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Erode</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1024x768, CV_8UC1)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_erode.js"></script>
|
||||
</body>
|
||||
</html>
|
120
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_erode.js
vendored
Normal file
120
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_erode.js
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const ErodeSize = [cvSize.szQVGA, cvSize.szVGA, cvSize.szSVGA, cvSize.szXGA, cvSize.szSXGA];
|
||||
const ErodeType = ["CV_8UC1", "CV_8UC4"];
|
||||
const combiErode = combine(ErodeSize, ErodeType);
|
||||
|
||||
function addErodeCase(suite, type) {
|
||||
suite.add('erode', function() {
|
||||
cv.erode(src, dst, kernel);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
let kernel = new cv.Mat();
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
kernel.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addErodeModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
|
||||
let params = {size: size, matType:matType};
|
||||
addKernelCase(suite, params, type, addErodeCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
let locationList = decodeParams2Case(params, paramObjs, erodeCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addErodeModeCase(suite, [erodeCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addErodeModeCase(suite, combiErode, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "erode", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from erode`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let erodeCombinations = [combiErode];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_filter2D.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_filter2D.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Filter2D</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (320x240, 3, BORDER_CONSTANT)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_filter2D.js"></script>
|
||||
</body>
|
||||
</html>
|
130
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_filter2D.js
vendored
Normal file
130
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_filter2D.js
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const Filter2dSize = [cvSize.szQVGA, cvSize.sz1080p];
|
||||
const Filter2dKsize = ["3", "5"];
|
||||
const Filter2dBorderMode = ["BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT_101"];
|
||||
const DISABLED_Filter2dBorderMode = ["BORDER_CONSTANT", "BORDER_REPLICATE"];
|
||||
const combiFilter2dCase = combine(Filter2dSize, Filter2dKsize, Filter2dBorderMode);
|
||||
const combiDISABLEDFilter2dCase = combine(Filter2dSize, Filter2dKsize, DISABLED_Filter2dBorderMode);
|
||||
|
||||
function addFilter2dCase(suite, type) {
|
||||
suite.add('filter2d', function() {
|
||||
cv.filter2D(src, dst, cv.CV_8UC4, kernel, new cv.Point(1, 1), 0.0, borderMode);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let ksize = parseInt(this.params.ksize);
|
||||
let borderMode = cv[this.params.borderMode];
|
||||
|
||||
let src = new cv.Mat(size, cv.CV_8UC4);
|
||||
let dst = new cv.Mat(size, cv.CV_8UC4);
|
||||
let kernelElement = [];
|
||||
for (let i = 0; i < ksize*ksize; i++) {
|
||||
let randNum = Math.random();
|
||||
kernelElement.push(-3.0+randNum*13.0);
|
||||
}
|
||||
let kernel = cv.matFromArray(ksize, ksize, cv.CV_32FC1, kernelElement);
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addFilter2dModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let ksize = combination[i][1];
|
||||
let borderMode = combination[i][2];
|
||||
let params = {size: size, ksize: ksize, borderMode:borderMode};
|
||||
addKernelCase(suite, params, type, addFilter2dCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*[0-9],[\ ]*BORDER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*[0-9],[\ ]*BORDER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"ksize", value:"", reg:["/\\b[0-9]\\b/"], index:1});
|
||||
paramObjs.push({name:"borderMode", value: "", reg:["/BORDER\_\\w+/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs,filter2dCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addFilter2dModeCase(suite, [filter2dCombinations[first][second]], 0);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addFilter2dModeCase(suite, combiFilter2dCase, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "filter2d", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from Filter2d`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let filter2dCombinations = [combiFilter2dCase];//,combiDISABLEDFilter2dCase];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*[0-9],[\ ]*BORDER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*[0-9],[\ ]*BORDER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_gaussianBlur.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_gaussianBlur.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>gaussianBlur</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1280x720, CV_8UC1, BORDER_REPLICATE)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_gaussianBlur.js"></script>
|
||||
</body>
|
||||
</html>
|
129
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_gaussianBlur.js
vendored
Normal file
129
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_gaussianBlur.js
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const GaussianBlurSize = [cvSize.szODD, cvSize.szQVGA, cvSize.szVGA, cvSize.sz720p];
|
||||
const GaussianBlurType = ["CV_8UC1", "CV_8UC4", "CV_16UC1", "CV_16SC1", "CV_32FC1"];
|
||||
const BorderType3x3 = ["BORDER_REPLICATE", "BORDER_CONSTANT"];
|
||||
const BorderType3x3ROI = ["BORDER_REPLICATE", "BORDER_CONSTANT", "BORDER_REFLECT", "BORDER_REFLECT101"];
|
||||
|
||||
const combiGaussianBlurBorder3x3 = combine(GaussianBlurSize, GaussianBlurType, BorderType3x3);
|
||||
const combiGaussianBlurBorder3x3ROI = combine(GaussianBlurSize, GaussianBlurType, BorderType3x3ROI);
|
||||
|
||||
function addGaussianBlurCase(suite, type) {
|
||||
suite.add('gaussianBlur', function() {
|
||||
cv.GaussianBlur(src, dst, ksize, 1, 0, borderType);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let borderType = cv[this.params.borderType];
|
||||
let type = this.params.type;
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
let ksizeNum = this.params.ksize;
|
||||
let ksize = new cv.Size(ksizeNum, ksizeNum);
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addGaussianBlurModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
let borderType = combination[i][2];
|
||||
let ksizeArray = [3, 5];
|
||||
let params = {size: size, matType:matType, ksize: ksizeArray[type], borderType:borderType};
|
||||
addKernelCase(suite, params, type, addGaussianBlurCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
paramObjs.push({name:"borderMode", value: "", reg:["/BORDER\_\\w+/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs,gaussianBlurCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addGaussianBlurModeCase(suite, [gaussianBlurCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addGaussianBlurModeCase(suite, combiGaussianBlurBorder3x3, 0);
|
||||
addGaussianBlurModeCase(suite, combiGaussianBlurBorder3x3ROI, 1);
|
||||
}
|
||||
setBenchmarkSuite(suite, "gaussianBlur", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from gaussianBlur`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let gaussianBlurCombinations = [combiGaussianBlurBorder3x3, combiGaussianBlurBorder3x3ROI];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_medianBlur.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_medianBlur.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>MedianBlur</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1280x720, CV_8UC1, 3)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_medianBlur.js"></script>
|
||||
</body>
|
||||
</html>
|
121
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_medianBlur.js
vendored
Normal file
121
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_medianBlur.js
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const MedianBlurSize = [cvSize.szODD, cvSize.szQVGA, cvSize.szVGA, cvSize.sz720p];
|
||||
const MedianBlurType = ["CV_8UC1", "CV_8UC4", "CV_16UC1", "CV_16SC1", "CV_32FC1"];
|
||||
const combiMedianBlur = combine(MedianBlurSize, MedianBlurType, [3,5]);
|
||||
|
||||
function addMedianBlurCase(suite, type) {
|
||||
suite.add('medianBlur', function() {
|
||||
cv.medianBlur(src, dst, ksize);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let ksize = this.params.ksize;
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addMedianBlurModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
let ksize = combination[i][2];
|
||||
|
||||
let params = {size: size, matType:matType, ksize: ksize};
|
||||
addKernelCase(suite, params, type, addMedianBlurCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*(3|5)\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*(3|5)\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
paramObjs.push({name:"ksize", value: "", reg:["/\\b[0-9]\\b/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs, medianBlurCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addMedianBlurModeCase(suite, [medianBlurCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addMedianBlurModeCase(suite, combiMedianBlur, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "medianBlur", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from medianBlur`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let medianBlurCombinations = [combiMedianBlur];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*(3|5)\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*(3|5)\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_pyrDown.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_pyrDown.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>pyrDown</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1920x1080, CV_8UC3)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_pyrDown.js"></script>
|
||||
</body>
|
||||
</html>
|
119
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_pyrDown.js
vendored
Normal file
119
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_pyrDown.js
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const PyrDownSize = [cvSize.sz1080p, cvSize.sz720p, cvSize.szVGA, cvSize.szQVGA, cvSize.szODD];
|
||||
const PyrDownType = ["CV_8UC1", "CV_8UC3", "CV_8UC4", "CV_16SC1", "CV_16SC3", "CV_16SC4", "CV_32FC1", "CV_32FC3", "CV_32FC4"];
|
||||
|
||||
const combiPyrDown = combine(PyrDownSize, PyrDownType);
|
||||
|
||||
function addPryDownCase(suite, type) {
|
||||
suite.add('pyrDown', function() {
|
||||
cv.pyrDown(src, dst);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat((size.height + 1)/2, (size.height + 1)/2, matType)
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addPyrDownModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
|
||||
let params = {size: size, matType:matType};
|
||||
addKernelCase(suite, params, type, addPryDownCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
let locationList = decodeParams2Case(params, paramObjs, pyrDownCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addPyrDownModeCase(suite, [pyrDownCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addPyrDownModeCase(suite, combiPyrDown, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "pyrDown", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from pyrDown`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let pyrDownCombinations = [combiPyrDown];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_remap.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_remap.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Remap</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480, CV_16UC1, CV_16SC2, INTER_NEAREST)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_remap.js"></script>
|
||||
</body>
|
||||
</html>
|
185
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_remap.js
vendored
Normal file
185
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_remap.js
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const RemapSize = [cvSize.szVGA, cvSize.sz1080p];
|
||||
const RemapSrcType = ["CV_16UC1", "CV_16SC1", "CV_32FC1"];
|
||||
const RemapType = ["CV_16SC2", "CV_32FC1", "CV_32FC2"];
|
||||
const InterType = ["INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_LANCZOS4"];
|
||||
const combiRemap = combine(RemapSize, RemapSrcType, RemapType, InterType);
|
||||
|
||||
function addRemapCase(suite, type) {
|
||||
suite.add('remap', function() {
|
||||
cv.remap(src, dst, map1, map2, interType);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let matType = cv[this.params.matType];
|
||||
let mapType = cv[this.params.mapType];
|
||||
let interType = cv[this.params.interType];
|
||||
|
||||
|
||||
let src = new cv.Mat(size, matType);
|
||||
let dst = new cv.Mat(size, matType);
|
||||
let map1 = new cv.Mat(size, mapType);
|
||||
let map2;
|
||||
if (mapType == cv.CV_32FC1) {
|
||||
map2 = new cv.Mat(size, mapType);
|
||||
} else if (interType != cv.INTER_NEAREST && mapType == cv.CV_16SC2) {
|
||||
map2 = new cv.Mat.zeros(size, cv.CV_16UC1);
|
||||
} else {
|
||||
map2 = new cv.Mat();
|
||||
}
|
||||
|
||||
for (let j = 0; j < map1.rows; j++) {
|
||||
for (let i = 0; i < map1.cols; i++) {
|
||||
let randNum = Math.random();
|
||||
let view, view1;
|
||||
switch(matType) {
|
||||
case cv.CV_16UC1:
|
||||
view = src.ushortPtr(j,i);
|
||||
view[0] = Math.floor(randNum*256);
|
||||
break;
|
||||
case cv.CV_16SC1:
|
||||
view = src.shortPtr(j,i);
|
||||
view[0] = Math.floor(randNum*256);
|
||||
break;
|
||||
case cv.CV_32FC1:
|
||||
view = src.floatPtr(j,i);
|
||||
view[0] = randNum*256;
|
||||
break;
|
||||
default:
|
||||
console.error("Unknown conversion type 1");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(mapType) {
|
||||
case cv.CV_32FC1:
|
||||
view1 = map1.floatPtr(j,i);
|
||||
let view2 = map2.floatPtr(j,i);
|
||||
view1[0] = src.cols - i - 1;
|
||||
view2[0] = j;
|
||||
break;
|
||||
case cv.CV_32FC2:
|
||||
view1 = map1.floatPtr(j,i);
|
||||
view1[0] = src.cols - i - 1;
|
||||
view1[1] = j;
|
||||
break;
|
||||
case cv.CV_16SC2:
|
||||
view1 = map1.shortPtr(j,i);
|
||||
view1[0] = src.cols - i - 1;
|
||||
view1[1] = j;
|
||||
break;
|
||||
default:
|
||||
console.error("Unknown conversion type 2");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
map1.delete();
|
||||
map2.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addRemapModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let matType = combination[i][1];
|
||||
let mapType = combination[i][2];
|
||||
let interType = combination[i][3];
|
||||
|
||||
let params = {size: size, matType:matType, mapType:mapType, interType:interType};
|
||||
addKernelCase(suite, params, type, addRemapCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*CV\_\w+,[\ ]*INTER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*CV\_\w+,[\ ]*INTER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/"], index:1});
|
||||
paramObjs.push({name:"mapType", value:"", reg:["/CV\_[0-9]+[FSUfsu]C[0-9]/g"], index:2, loc:1});
|
||||
paramObjs.push({name:"interType", value: "", reg:["/INTER\_\\w+/"], index:3});
|
||||
let locationList = decodeParams2Case(params, paramObjs, remapCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addRemapModeCase(suite, [remapCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addRemapModeCase(suite, combiRemap, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "remap", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from remap`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let remapCombinations = [combiRemap];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*CV\_\w+,[\ ]*INTER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*CV\_\w+,[\ ]*INTER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_resize.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_resize.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Resize</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (CV_8UC1,640x480,960x540)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_resize.js"></script>
|
||||
</body>
|
||||
</html>
|
169
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_resize.js
vendored
Normal file
169
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_resize.js
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.fillGradient = HelpFunc.fillGradient;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const matTypesUpLinear = ['CV_8UC1', 'CV_8UC2', 'CV_8UC3', 'CV_8UC4'];
|
||||
const size1UpLinear = [cvSize.szVGA];
|
||||
const size2UpLinear = [cvSize.szqHD, cvSize.sz720p];
|
||||
const combiUpLinear = combine(matTypesUpLinear, size1UpLinear, size2UpLinear);
|
||||
|
||||
const combiDownLinear = [
|
||||
['CV_8UC1', cvSize.szVGA, cvSize.szQVGA],
|
||||
['CV_8UC2', cvSize.szVGA, cvSize.szQVGA],
|
||||
['CV_8UC3', cvSize.szVGA, cvSize.szQVGA],
|
||||
['CV_8UC4', cvSize.szVGA, cvSize.szQVGA],
|
||||
['CV_8UC1', cvSize.szqHD, cvSize.szVGA],
|
||||
['CV_8UC2', cvSize.szqHD, cvSize.szVGA],
|
||||
['CV_8UC3', cvSize.szqHD, cvSize.szVGA],
|
||||
['CV_8UC4', cvSize.szqHD, cvSize.szVGA],
|
||||
['CV_8UC1', cvSize.sz720p, cvSize.sz213x120],// face detection min_face_size = 20%
|
||||
['CV_8UC2', cvSize.sz720p, cvSize.sz213x120],// face detection min_face_size = 20%
|
||||
['CV_8UC3', cvSize.sz720p, cvSize.sz213x120],// face detection min_face_size = 20%
|
||||
['CV_8UC4', cvSize.sz720p, cvSize.sz213x120],// face detection min_face_size = 20%
|
||||
['CV_8UC1', cvSize.sz720p, cvSize.szVGA],
|
||||
['CV_8UC2', cvSize.sz720p, cvSize.szVGA],
|
||||
['CV_8UC3', cvSize.sz720p, cvSize.szVGA],
|
||||
['CV_8UC4', cvSize.sz720p, cvSize.szVGA],
|
||||
['CV_8UC1', cvSize.sz720p, cvSize.szQVGA],
|
||||
['CV_8UC2', cvSize.sz720p, cvSize.szQVGA],
|
||||
['CV_8UC3', cvSize.sz720p, cvSize.szQVGA],
|
||||
['CV_8UC4', cvSize.sz720p, cvSize.szQVGA]
|
||||
];
|
||||
|
||||
const matTypesAreaFast = ['CV_8UC1', 'CV_8UC3', 'CV_8UC4', 'CV_16UC1', 'CV_16UC3', 'CV_16UC4'];
|
||||
const sizesAreaFast = [cvSize.szVGA, cvSize.szqHD, cvSize.sz720p, cvSize.sz1080p];
|
||||
const scalesAreaFast = [2];
|
||||
const combiAreaFast = combine(matTypesAreaFast, sizesAreaFast, scalesAreaFast);
|
||||
|
||||
function addResizeCase(suite, type) {
|
||||
suite.add('resize', function() {
|
||||
if (type == "area") {
|
||||
cv.resize(src, dst, dst.size(), 0, 0, cv.INTER_AREA);
|
||||
} else {
|
||||
cv.resize(src, dst, to, 0, 0, cv.INTER_LINEAR_EXACT);
|
||||
}
|
||||
}, {
|
||||
'setup': function() {
|
||||
let from = this.params.from;
|
||||
let to = this.params.to;
|
||||
let matType = cv[this.params.matType];
|
||||
let src = new cv.Mat(from, matType);
|
||||
let type = this.params.modeType;
|
||||
let dst;
|
||||
if (type == "area") {
|
||||
dst = new cv.Mat(from.height/scale, from.width/scale, matType);
|
||||
} else {
|
||||
dst = new cv.Mat(to, matType);
|
||||
fillGradient(cv, src);
|
||||
}
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addResizeModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let matType = combination[i][0];
|
||||
let from = combination[i][1];
|
||||
let params;
|
||||
if (type == "area") {
|
||||
let scale = combination[i][2];
|
||||
params = { from: from, scale: scale, matType: matType, modeType: type };
|
||||
} else {
|
||||
let to = combination[i][2];
|
||||
params = { from: from, to: to, matType: matType, modeType: type};
|
||||
}
|
||||
addKernelCase(suite, params, type, addResizeCase)
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
if (/\(\w+,[\ ]*[0-9]+x[0-9]+,[\ ]*[0-9]+x[0-9]+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\(\w+,[\ ]*[0-9]+x[0-9]+,[\ ]*[0-9]+x[0-9]+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[A-z][A-z][0-9]/"], index:0});
|
||||
paramObjs.push({name:"size1", value:"", reg:[""], index:1});
|
||||
paramObjs.push({name:"size2", value:"", reg:[""], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs,combinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addResizeModeCase(suite, [combinations[first][second]], "linear");
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addResizeModeCase(suite, combiUpLinear, "linear");
|
||||
addResizeModeCase(suite, combiDownLinear, "linear");
|
||||
}
|
||||
setBenchmarkSuite(suite, "resize", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from Resize`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
// init
|
||||
let combinations = [combiUpLinear, combiDownLinear];//, combiAreaFast];
|
||||
|
||||
// set test filter params
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\(\w+,[\ ]*[0-9]+x[0-9]+,[\ ]*[0-9]+x[0-9]+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\(\w+,[\ ]*[0-9]+x[0-9]+,[\ ]*[0-9]+x[0-9]+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_scharr.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_scharr.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Scharr</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480, CV_16SC1, (0,1), BORDER_REPLICATE)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_scharr.js"></script>
|
||||
</body>
|
||||
</html>
|
159
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_scharr.js
vendored
Normal file
159
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_scharr.js
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const ScharrSize = [cvSize.szODD, cvSize.szQVGA, cvSize.szVGA];
|
||||
const Scharrdxdy = ["(1,0)", "(0,1)"];
|
||||
const BorderType3x3 = ["BORDER_REPLICATE", "BORDER_CONSTANT"];
|
||||
const BorderType3x3ROI = ["BORDER_DEFAULT", "BORDER_REPLICATE|BORDER_ISOLATED", "BORDER_CONSTANT|BORDER_ISOLATED"];
|
||||
|
||||
const combiScharrBorder3x3 = combine(ScharrSize, ["CV_16SC1", "CV_32FC1"], Scharrdxdy, BorderType3x3);
|
||||
const combiScharrBorder3x3ROI = combine(ScharrSize, ["CV_16SC1", "CV_32FC1"], Scharrdxdy, BorderType3x3ROI);
|
||||
|
||||
function addScharrCase(suite, type) {
|
||||
suite.add('scharr', function() {
|
||||
cv.Scharr(src, dst, ddepth, dx, dy, 1, 0, borderType);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let ddepth = cv[this.params.ddepth];
|
||||
let dxdy = this.params.dxdy;
|
||||
let type = this.params.type;
|
||||
let src, dst;
|
||||
if (type == 0) {
|
||||
src = new cv.Mat(size[1], size[0], cv.CV_8U);
|
||||
dst = new cv.Mat(size[1], size[0], ddepth);
|
||||
} else {
|
||||
src = new cv.Mat(size[1]+10, size[0]+10, cv.CV_8U);
|
||||
dst = new cv.Mat(size[1]+10, size[0]+10, ddepth);
|
||||
src = src.colRange(5, size[0]+5);
|
||||
src = src.rowRange(5, size[1]+5);
|
||||
dst = dst.colRange(5, size[0]+5);
|
||||
dst = dst.rowRange(5, size[1]+5);
|
||||
}
|
||||
|
||||
let dx = parseInt(dxdy[1]);
|
||||
let dy = parseInt(dxdy[3]);
|
||||
let borderTypeArray = this.params.borderType;
|
||||
let borderType;
|
||||
if (borderTypeArray.length == 1) {
|
||||
borderType = cv[borderTypeArray[0]];
|
||||
} else {
|
||||
borderType = cv[borderTypeArray[0]] | cv[borderTypeArray[1]];
|
||||
}
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addScharrModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let ddepth = combination[i][1];
|
||||
let dxdy = combination[i][2];
|
||||
let borderType = combination[i][3];
|
||||
let sizeArray = [size.width, size.height];
|
||||
|
||||
let borderTypeArray = borderType.split("|");
|
||||
let params = {size: sizeArray, ddepth: ddepth, dxdy: dxdy, borderType:borderTypeArray, type:type};
|
||||
addKernelCase(suite, params, type, addScharrCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
let params = "";
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"ddepth", value:"", reg:["/CV\_[0-9]+[FSUfsu]C1/g"], index:1});
|
||||
paramObjs.push({name:"dxdy", value:"", reg:["/\\([0-2],[0-2]\\)/"], index:2});
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g)[0];
|
||||
paramObjs.push({name:"boderType", value:"", reg:["/BORDER\_\\w+/"], index:3});
|
||||
} else if (/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g)[0];
|
||||
paramObjs.push({name:"boderType", value:"", reg:["/BORDER\_\\w+\\|BORDER\_\\w+/"], index:3});
|
||||
}
|
||||
|
||||
if (params != ""){
|
||||
let locationList = decodeParams2Case(params, paramObjs,scharrCombinations);
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addScharrModeCase(suite, [scharrCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addScharrModeCase(suite, combiScharrBorder3x3, 0);
|
||||
addScharrModeCase(suite, combiScharrBorder3x3ROI, 1);
|
||||
}
|
||||
setBenchmarkSuite(suite, "scharr", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from Scharr`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let scharrCombinations = [combiScharrBorder3x3, combiScharrBorder3x3ROI];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g)[0];
|
||||
} else if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_sobel.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_sobel.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Sobel</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480, CV_16SC1, (0,1), BORDER_REPLICATE)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_sobel.js"></script>
|
||||
</body>
|
||||
</html>
|
173
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_sobel.js
vendored
Normal file
173
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_sobel.js
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const SobelSize = [cvSize.szODD, cvSize.szQVGA, cvSize.szVGA];
|
||||
const Sobel3x3dxdy = ["(0,1)", "(1,0)", "(1,1)", "(0,2)", "(2,0)", "(2,2)"];
|
||||
const Sobeldxdy = ["(0,1)", "(1,0)", "(1,1)", "(0,2)", "(2,0)"];
|
||||
const BorderType3x3 = ["BORDER_REPLICATE", "BORDER_CONSTANT"];
|
||||
const BorderType3x3ROI = ["BORDER_DEFAULT", "BORDER_REPLICATE|BORDER_ISOLATED", "BORDER_CONSTANT|BORDER_ISOLATED"];
|
||||
const BorderType = ["BORDER_REPLICATE", "BORDER_CONSTANT", "BORDER_REFLECT", "BORDER_REFLECT101"];
|
||||
const BorderTypeROI = ["BORDER_DEFAULT", "BORDER_REPLICATE|BORDER_ISOLATED", "BORDER_CONSTANT|BORDER_ISOLATED", "BORDER_REFLECT|BORDER_ISOLATED", "BORDER_REFLECT101|BORDER_ISOLATED"]
|
||||
|
||||
const combiSobelBorder3x3 = combine(SobelSize, ["CV_16SC1", "CV_32FC1"], Sobel3x3dxdy, BorderType3x3);
|
||||
const combiSobelBorder3x3ROI = combine(SobelSize, ["CV_16SC1", "CV_32FC1"], Sobel3x3dxdy, BorderType3x3ROI);
|
||||
const combiSobelBorder5x5 = combine(SobelSize, ["CV_16SC1", "CV_32FC1"], Sobeldxdy, BorderType);
|
||||
const combiSobelBorder5x5ROI = combine(SobelSize, ["CV_16SC1", "CV_32FC1"], Sobeldxdy, BorderTypeROI);
|
||||
|
||||
function addSobelCase(suite, type) {
|
||||
suite.add('sobel', function() {
|
||||
cv.Sobel(src, dst, ddepth, dx, dy, ksize, 1, 0, borderType);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let size = this.params.size;
|
||||
let ddepth = cv[this.params.ddepth];
|
||||
let dxdy = this.params.dxdy;
|
||||
let ksize = this.params.ksize;
|
||||
let type = this.params.type;
|
||||
let src, dst;
|
||||
if (type %2 == 0) {
|
||||
src = new cv.Mat(size[1], size[0], cv.CV_8U);
|
||||
dst = new cv.Mat(size[1], size[0], ddepth);
|
||||
} else {
|
||||
src = new cv.Mat(size[1]+10, size[0]+10, cv.CV_8U);
|
||||
dst = new cv.Mat(size[1]+10, size[0]+10, ddepth);
|
||||
src = src.colRange(5, size[0]+5);
|
||||
src = src.rowRange(5, size[1]+5);
|
||||
dst = dst.colRange(5, size[0]+5);
|
||||
dst = dst.rowRange(5, size[1]+5);
|
||||
}
|
||||
|
||||
let dx = parseInt(dxdy[1]);
|
||||
let dy = parseInt(dxdy[3]);
|
||||
let borderTypeArray = this.params.borderType;
|
||||
let borderType;
|
||||
if (borderTypeArray.length == 1) {
|
||||
borderType = cv[borderTypeArray[0]];
|
||||
} else {
|
||||
borderType = cv[borderTypeArray[0]] | cv[borderTypeArray[1]];
|
||||
}
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addSobelModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let ddepth = combination[i][1];
|
||||
let dxdy = combination[i][2];
|
||||
let borderType = combination[i][3];
|
||||
let sizeArray = [size.width, size.height];
|
||||
let ksize;
|
||||
if (type < 2) {
|
||||
ksize = 3;
|
||||
} else {
|
||||
ksize = 5;
|
||||
}
|
||||
|
||||
let borderTypeArray = borderType.split("|");
|
||||
let params = {size: sizeArray, ddepth: ddepth, dxdy: dxdy, ksize:ksize, borderType:borderTypeArray, type:type};
|
||||
addKernelCase(suite, params, type, addSobelCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
let params = "";
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"ddepth", value:"", reg:["/CV\_[0-9]+[FSUfsu]C1/g"], index:1});
|
||||
paramObjs.push({name:"dxdy", value:"", reg:["/\\([0-2],[0-2]\\)/"], index:2});
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g)[0];
|
||||
paramObjs.push({name:"boderType", value:"", reg:["/BORDER\_\\w+/"], index:3});
|
||||
} else if (/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g)[0];
|
||||
paramObjs.push({name:"boderType", value:"", reg:["/BORDER\_\\w+\\|BORDER\_\\w+/"], index:3});
|
||||
}
|
||||
|
||||
if (params != ""){
|
||||
let locationList = decodeParams2Case(params, paramObjs,sobelCombinations);
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addSobelModeCase(suite, [sobelCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addSobelModeCase(suite, combiSobelBorder3x3, 0);
|
||||
addSobelModeCase(suite, combiSobelBorder3x3ROI, 1);
|
||||
addSobelModeCase(suite, combiSobelBorder5x5, 2);
|
||||
addSobelModeCase(suite, combiSobelBorder5x5ROI, 3);
|
||||
}
|
||||
setBenchmarkSuite(suite, "sobel", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from Sobel`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let sobelCombinations = [combiSobelBorder3x3, combiSobelBorder3x3ROI, combiSobelBorder5x5, combiSobelBorder5x5ROI];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\)/g)[0];
|
||||
} else if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*\w+,[\ ]*\([0-2],[0-2]\),[\ ]*\w+\|\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_threshold.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_threshold.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>Threshold</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (1920x1080, CV_8UC1, THRESH_BINARY)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_threshold.js"></script>
|
||||
</body>
|
||||
</html>
|
161
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_threshold.js
vendored
Normal file
161
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_threshold.js
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase;
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const typicalMatSizes = [cvSize.szVGA, cvSize.sz720p, cvSize.sz1080p, cvSize.szODD];
|
||||
const matTypes = ['CV_8UC1', 'CV_16SC1', 'CV_32FC1', 'CV_64FC1'];
|
||||
const threshTypes = ['THRESH_BINARY', 'THRESH_BINARY_INV', 'THRESH_TRUNC', 'THRESH_TOZERO', 'THRESH_TOZERO_INV'];
|
||||
|
||||
const combiSizeMatTypeThreshType = combine(typicalMatSizes, matTypes, threshTypes);
|
||||
const combiSizeOnly = combine(typicalMatSizes, ['CV_8UC1'], ['THRESH_BINARY|THRESH_OTSU']);
|
||||
|
||||
|
||||
function addThresholdCase(suite, type) {
|
||||
suite.add('threshold', function() {
|
||||
if (type == "sizeonly") {
|
||||
cv.threshold(src, dst, threshold, thresholdMax, cv.THRESH_BINARY|cv.THRESH_OTSU);
|
||||
} else {
|
||||
cv.threshold(src, dst, threshold, thresholdMax, threshType);
|
||||
}
|
||||
}, {
|
||||
'setup': function() {
|
||||
let matSize = this.params.matSize;
|
||||
let type = this.params.modeType;
|
||||
let src, dst, matType, threshType;
|
||||
if (type == "sizeonly") {
|
||||
src = new cv.Mat(matSize, cv.CV_8UC1);
|
||||
dst = new cv.Mat(matSize, cv.CV_8UC1);
|
||||
} else {
|
||||
matType = cv[this.params.matType];
|
||||
threshType = cv[this.params.threshType];
|
||||
src = new cv.Mat(matSize, matType);
|
||||
dst = new cv.Mat(matSize, matType);
|
||||
}
|
||||
let threshold = 127.0;
|
||||
let thresholdMax = 210.0;
|
||||
let srcView = src.data;
|
||||
srcView[0] = 0;
|
||||
srcView[1] = 100;
|
||||
srcView[2] = 200;
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addThresholdModecase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let matSize = combination[i][0];
|
||||
let matType = 'CV_8UC1';
|
||||
let threshType = 'THRESH_BINARY|THRESH_OTSU';
|
||||
if (type != "sizeonly") {
|
||||
matType = combination[i][1];
|
||||
threshType = combination[i][2];
|
||||
}
|
||||
let params = {matSize: matSize, matType: matType, threshType: threshType, modeType: type};
|
||||
addKernelCase(suite, params, type, addThresholdCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
let params = "";
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*THRESH\_\w+\)/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*THRESH\_\w+\)/g)[0];
|
||||
paramObjs.push({name:"matType", value:"", reg:["/CV\_[0-9]+[A-z][A-z][0-9]/"], index:1});
|
||||
paramObjs.push({name:"threshType", value:"", reg:["/THRESH\_[A-z]+\_?[A-z]*/"], index:2});
|
||||
} else if (/[\ ]*[0-9]+x[0-9]+[\ ]*/g.test(paramsContent.toString())) {
|
||||
params = paramsContent.toString().match(/[\ ]*[0-9]+x[0-9]+[\ ]*/g)[0];
|
||||
paramObjs.push({name:"matType", value:"CV_8UC1", reg:[""], index:1});
|
||||
paramObjs.push({name:"threshType", value:"THRESH_BINARY|THRESH_OTSU", reg:[""], index:2});
|
||||
}
|
||||
|
||||
if(params != ""){
|
||||
let locationList = decodeParams2Case(params, paramObjs,combinations);
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
if (first == 0) {
|
||||
addThresholdModecase(suite, [combinations[first][second]], "normal");
|
||||
} else {
|
||||
addThresholdModecase(suite, [combinations[first][second]], "sizeonly");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addThresholdModecase(suite, combiSizeMatTypeThreshType, "normal");
|
||||
addThresholdModecase(suite, combiSizeOnly, "sizeonly");
|
||||
}
|
||||
setBenchmarkSuite(suite, "threshold", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from Threshold`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
// init
|
||||
let combinations = [combiSizeMatTypeThreshType, combiSizeOnly];
|
||||
|
||||
// set test filter params
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*THRESH\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*CV\_\w+,[\ ]*THRESH\_\w+\)/g)[0];
|
||||
} else if (/--test_param_filter=[\ ]*[0-9]+x[0-9]+[\ ]*/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/[\ ]*[0-9]+x[0-9]+[\ ]*/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpAffine.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpAffine.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>warpAffine</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480, INTER_NEAREST, BORDER_CONSTANT)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_warpAffine.js"></script>
|
||||
</body>
|
||||
</html>
|
135
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpAffine.js
vendored
Normal file
135
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpAffine.js
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.fillGradient = HelpFunc.fillGradient;
|
||||
global.smoothBorder = HelpFunc.smoothBorder;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const WarpAffineSize = [cvSize.szVGA, cvSize.sz720p, cvSize.sz1080p];
|
||||
const InterType = ["INTER_NEAREST", "INTER_LINEAR"];
|
||||
const BorderMode = ["BORDER_CONSTANT", "BORDER_REPLICATE"]
|
||||
const combiWarpAffine = combine(WarpAffineSize, InterType, BorderMode);
|
||||
|
||||
function addWarpAffineCase(suite, type) {
|
||||
suite.add('warpAffine', function() {
|
||||
cv.warpAffine(src, dst, warpMat, sz, interType, borderMode, borderColor);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let sz = this.params.size;
|
||||
let interType = cv[this.params.interType];
|
||||
let borderMode = cv[this.params.borderMode];
|
||||
let srcSize = new cv.Size(512, 512);
|
||||
|
||||
let borderColor = new cv.Scalar.all(150);
|
||||
let src = new cv.Mat(srcSize, cv.CV_8UC4);
|
||||
let dst = new cv.Mat(sz, cv.CV_8UC4);
|
||||
fillGradient(cv, src);
|
||||
if (borderMode == cv.BORDER_CONSTANT) {
|
||||
smoothBorder(cv, src, borderMode, 1);
|
||||
}
|
||||
|
||||
let point = new cv.Point(src.cols/2.0, src.rows/2.0);
|
||||
let warpMat = cv.getRotationMatrix2D(point, 30.0, 2.2);
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
warpMat.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addWarpAffineModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let interType = combination[i][1];
|
||||
let borderMode = combination[i][2];
|
||||
|
||||
let params = {size: size, interType:interType, borderMode:borderMode};
|
||||
addKernelCase(suite, params, type, addWarpAffineCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"interType", value: "", reg:["/INTER\_\\w+/"], index:1});
|
||||
paramObjs.push({name:"borderMode", value: "", reg:["/BORDER\_\\w+/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs, warpAffineCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addWarpAffineModeCase(suite, [warpAffineCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addWarpAffineModeCase(suite, combiWarpAffine, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "warpAffine", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from warpAffine`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let warpAffineCombinations = [combiWarpAffine];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpPerspective.html
vendored
Normal file
73
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpPerspective.html
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenCV.js Performance Test</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-size: 13px;
|
||||
}
|
||||
.top-margin {
|
||||
margin-top:10px;
|
||||
}
|
||||
h1, h4 {
|
||||
margin: 24px 0 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2.0em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
pre {
|
||||
font-family: 'Consolas', 'Monaco', monospace, serif;
|
||||
font-size: 12px;
|
||||
tab-size: 2;
|
||||
}
|
||||
input[type=checkbox] {
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>OpenCV.js Performance Test</h1>
|
||||
<div>
|
||||
<h4>Modules</h4>
|
||||
<h7>Image Processing</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Kernels</h4>
|
||||
<h7>warpPerspective</h7>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters Filter</h4>
|
||||
<input type="text" id="params" min="1" size="40" placeholder="default: run all the case"/> for example: (640x480, INTER_NEAREST, BORDER_CONSTANT)
|
||||
</div>
|
||||
<div class='row labels-wrapper' id='labelitem'></div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<button type="button" id="runButton" class="btn btn-primary disabled" disabled="disabled">Loading</button>
|
||||
(It will take several minutes)</div>
|
||||
<div class="row top-margin">
|
||||
</div>
|
||||
<div>
|
||||
<pre id="log"></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/platform/1.3.5/platform.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/2.1.4/benchmark.js"></script>
|
||||
<script src="../../opencv.js" type="text/javascript"></script>
|
||||
<script src="../base.js"></script>
|
||||
<script src="../perf_helpfunc.js"></script>
|
||||
<script src="./perf_warpPerspective.js"></script>
|
||||
</body>
|
||||
</html>
|
148
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpPerspective.js
vendored
Normal file
148
3rdparty/opencv-4.5.4/modules/js/perf/perf_imgproc/perf_warpPerspective.js
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
const isNodeJs = (typeof window) === 'undefined'? true : false;
|
||||
|
||||
if (isNodeJs) {
|
||||
var Benchmark = require('benchmark');
|
||||
var cv = require('../../opencv');
|
||||
var HelpFunc = require('../perf_helpfunc');
|
||||
var Base = require('../base');
|
||||
} else {
|
||||
var paramsElement = document.getElementById('params');
|
||||
var runButton = document.getElementById('runButton');
|
||||
var logElement = document.getElementById('log');
|
||||
}
|
||||
|
||||
function perf() {
|
||||
|
||||
console.log('opencv.js loaded');
|
||||
if (isNodeJs) {
|
||||
global.cv = cv;
|
||||
global.fillGradient = HelpFunc.fillGradient;
|
||||
global.smoothBorder = HelpFunc.smoothBorder;
|
||||
global.combine = HelpFunc.combine;
|
||||
global.log = HelpFunc.log;
|
||||
global.decodeParams2Case = HelpFunc.decodeParams2Case;
|
||||
global.setBenchmarkSuite = HelpFunc.setBenchmarkSuite;
|
||||
global.addKernelCase = HelpFunc.addKernelCase
|
||||
global.cvSize = Base.getCvSize();
|
||||
} else {
|
||||
enableButton();
|
||||
cvSize = getCvSize();
|
||||
}
|
||||
let totalCaseNum, currentCaseId;
|
||||
|
||||
const WarpPersSize = [cvSize.szVGA, cvSize.sz720p, cvSize.sz1080p];
|
||||
const InterType = ["INTER_NEAREST", "INTER_LINEAR"];
|
||||
const BorderMode = ["BORDER_CONSTANT", "BORDER_REPLICATE"]
|
||||
const combiWarpPers = combine(WarpPersSize, InterType, BorderMode);
|
||||
|
||||
function addWarpPerspectiveCase(suite, type) {
|
||||
suite.add('warpPerspective', function() {
|
||||
cv.warpPerspective(src, dst, warpMat, sz, interType, borderMode, borderColor);
|
||||
}, {
|
||||
'setup': function() {
|
||||
let sz = this.params.size;
|
||||
let interType = cv[this.params.interType];
|
||||
let borderMode = cv[this.params.borderMode];
|
||||
let srcSize = new cv.Size(512, 512);
|
||||
|
||||
let borderColor = new cv.Scalar.all(150);
|
||||
let src = new cv.Mat(srcSize, cv.CV_8UC4);
|
||||
let dst = new cv.Mat(sz, cv.CV_8UC4);
|
||||
fillGradient(cv, src);
|
||||
if (borderMode == cv.BORDER_CONSTANT) {
|
||||
smoothBorder(cv, src, borderMode, 1);
|
||||
}
|
||||
|
||||
let rotMat = cv.getRotationMatrix2D(new cv.Point(src.cols/2.0, src.rows/2.0), 30.0, 2.2);
|
||||
let warpMat = new cv.Mat(3, 3, cv.CV_64FC1);
|
||||
|
||||
for(r=0; r<2; r++) {
|
||||
for(c=0; c<3; c++) {
|
||||
view = warpMat.doublePtr(r,c)
|
||||
view[0] = rotMat.doubleAt(r, c);
|
||||
}
|
||||
}
|
||||
view = warpMat.doublePtr(2,0);
|
||||
view[0] = 0.3/sz.width;
|
||||
view = warpMat.doublePtr(2,1);
|
||||
view[0] = 0.3/sz.height;
|
||||
view = warpMat.doublePtr(2,2);
|
||||
view[0] = 1;
|
||||
},
|
||||
'teardown': function() {
|
||||
src.delete();
|
||||
dst.delete();
|
||||
warpMat.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addWarpPerspectiveModeCase(suite, combination, type) {
|
||||
totalCaseNum += combination.length;
|
||||
for (let i = 0; i < combination.length; ++i) {
|
||||
let size = combination[i][0];
|
||||
let interType = combination[i][1];
|
||||
let borderMode = combination[i][2];
|
||||
|
||||
let params = {size: size, interType:interType, borderMode:borderMode};
|
||||
addKernelCase(suite, params, type, addWarpPerspectiveCase);
|
||||
}
|
||||
}
|
||||
|
||||
function genBenchmarkCase(paramsContent) {
|
||||
let suite = new Benchmark.Suite;
|
||||
totalCaseNum = 0;
|
||||
currentCaseId = 0;
|
||||
|
||||
if (/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g.test(paramsContent.toString())) {
|
||||
let params = paramsContent.toString().match(/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
let paramObjs = [];
|
||||
paramObjs.push({name:"size", value:"", reg:[""], index:0});
|
||||
paramObjs.push({name:"interType", value: "", reg:["/INTER\_\\w+/"], index:1});
|
||||
paramObjs.push({name:"borderMode", value: "", reg:["/BORDER\_\\w+/"], index:2});
|
||||
let locationList = decodeParams2Case(params, paramObjs, warpPersCombinations);
|
||||
|
||||
for (let i = 0; i < locationList.length; i++){
|
||||
let first = locationList[i][0];
|
||||
let second = locationList[i][1];
|
||||
addWarpPerspectiveModeCase(suite, [warpPersCombinations[first][second]], first);
|
||||
}
|
||||
} else {
|
||||
log("no filter or getting invalid params, run all the cases");
|
||||
addWarpPerspectiveModeCase(suite, combiWarpPers, 0);
|
||||
}
|
||||
setBenchmarkSuite(suite, "warpPerspective", currentCaseId);
|
||||
log(`Running ${totalCaseNum} tests from warpPerspective`);
|
||||
suite.run({ 'async': true }); // run the benchmark
|
||||
}
|
||||
|
||||
let warpPersCombinations = [combiWarpPers];
|
||||
|
||||
if (isNodeJs) {
|
||||
const args = process.argv.slice(2);
|
||||
let paramsContent = '';
|
||||
if (/--test_param_filter=\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g.test(args.toString())) {
|
||||
paramsContent = args.toString().match(/\([0-9]+x[0-9]+,[\ ]*INTER\_\w+,[\ ]*BORDER\_\w+\)/g)[0];
|
||||
}
|
||||
genBenchmarkCase(paramsContent);
|
||||
} else {
|
||||
runButton.onclick = function() {
|
||||
let paramsContent = paramsElement.value;
|
||||
genBenchmarkCase(paramsContent);
|
||||
if (totalCaseNum !== 0) {
|
||||
disableButton();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
async function main() {
|
||||
if (cv instanceof Promise) {
|
||||
cv = await cv;
|
||||
perf();
|
||||
} else {
|
||||
cv.onRuntimeInitialized = perf;
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
Reference in New Issue
Block a user