Node Version: v18.17.1
OS:windows 10 x64
import cvModule, { CV } from "@techstark/opencv-js";
async function getOpenCv():Promise<{ cv: CV }> {
let cv;
if (cvModule instanceof Promise) {
cv = await cvModule;
} else {
await new Promise((resolve) => {
cvModule.onRuntimeInitialized = () => resolve(1);
});
cv = cvModule;
}
return { cv };
}
async function main() {
const { cv } = await getOpenCv();
console.log("OpenCV.js is ready!");
// You can now use OpenCV functions here
console.log(cv.getBuildInformation());
let mat=new cv.Mat(100,100,cv.CV_8UC3,new cv.Scalar(255,0,0))
cv.imshow("mat:",mat)
}
main();
Run command:
But if you really need to explain, keep it under 200 words:
- What happened
- The program frantically outputs commands to the command line, causing it to freeze and crash.
- What I expected
- Error stack trace
- Unable to track, the program outputs incessantly, causing the editor to freeze.
- Documentation links