forked from echamudi/opencv-wasm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
30 lines (27 loc) · 981 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module.exports = {
cv: require('./opencv.js'),
cvTranslateError: function (cv, err) {
// Code modified from OpenCV TryIt playground
// https://docs.opencv.org/3.4/d0/d84/tutorial_js_usage.html
let errorStatement;
if (typeof err === 'undefined') {
errorStatement = '';
} else if (typeof err === 'number') {
if (!isNaN(err)) {
if (typeof cv !== 'undefined') {
errorStatement = 'Exception: ' + cv.exceptionFromPtr(err).msg;
}
}
} else if (typeof err === 'string') {
let ptr = Number(err.split(' ')[0]);
if (!isNaN(ptr)) {
if (typeof cv !== 'undefined') {
errorStatement = 'Exception: ' + cv.exceptionFromPtr(ptr).msg;
}
}
} else if (err instanceof Error) {
errorStatement = err;
}
return errorStatement;
}
};