Skip to content

I'm using TSX to load OpenCV-JS in TypeScript, and it's outputting errors like crazy, causing the editor to freeze and the program to crash. #108

@automan-bot

Description

@automan-bot

Node Version: v18.17.1
OS:windows 10 x64

  • test.ts
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:

tsx ./test.ts

But if you really need to explain, keep it under 200 words:

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions