-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
26 lines (22 loc) · 847 Bytes
/
main.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
const cv = require('./node-opencv-rs.node');
const { promisify } = require('util');
const imdecodeAsync = promisify(cv.imdecodeCallback);
const imreadAsync = promisify(cv.imreadCallback);
const imencodeAsync = promisify(cv.imencodeCallback);
cv.Mat.prototype.matchTemplateAsync = promisify(cv.Mat.prototype.matchTemplateCallback);
cv.Mat.prototype.matchTemplateAllAsync = promisify(cv.Mat.prototype.matchTemplateAllCallback);
cv.Mat.prototype.minMaxLocAsync = promisify(cv.Mat.prototype.minMaxLocCallback);
const cvProxy = new Proxy(cv, {
get(target, prop) {
if (prop === 'imdecodeAsync') {
return imdecodeAsync;
} else if (prop === 'imreadAsync') {
return imreadAsync;
} else if (prop === 'imencodeAsync') {
return imencodeAsync;
} else {
return target[prop];
}
}
});
module.exports = cvProxy;