Hi!
I am new to openCV and am trying to apply in a TypeScript project.
I tested it following the instruction on the openCV documentation for using in node.js environment and it worked fine. However, it does not seem to work with the very same code (makes sense since that’s what TypeScript is for).
I found this solution on Github issue section guiding to do npm i mirada
which solves type declaration problem in TypeScript.
So if I include console.log('testing..!!')
in opencv.js
file (the one on the opencv documentation for nodejs), I do see the output string on terminal so I figured that it is imported fine.
My final goal is to warp an image like this here in the last example.
The problems are:
- I cannot use cv.imread()
I keep seeingHTMLImageElement is not defined
as an error message on terminal.
So I used an workaround for reading an image like this
Jimp.read('./lena.jpg')
.then((lena) => {
var src = cv.matFromImageData(lena.bitmap);
let dst = new cv.Mat();
...
})
- When I console.log()
const output = cv.warpPerspective(src, dst, M, dsize, cv.INTER_LINEAR, cv.BORDER_CONSTANT, new cv.Scalar());
, it does not show or do anything.
If anyone knows how I openCV can be used in TypeScript, please share!
Thanks, everyone!
Happy Coding!