TechStark / opencv-js

OpenCV JavaScript version for node.js or browser
https://npmjs.com/@techstark/opencv-js
Apache License 2.0
439 stars 38 forks source link

Want to know if this opencv-js can be used in Angular10 #2

Closed WisarutBholsithi closed 3 years ago

WisarutBholsithi commented 3 years ago

Dear Sir,

I would like know whether this opencv-js can be used in Angular10 or only for React platform. If it can be use in Angular Platform, I would like to know how to implement the system to enable to use OpenCV.js

ttt43ttt commented 3 years ago

@WisarutBholsithi this opencv-js does not bind anything to React. You can use it in Angular for sure. use import cv from "@techstark/opencv-js" then you can call method on cv.

WisarutBholsithi commented 3 years ago

@WisarutBholsithi this opencv-js does not bind anything to React. You can use it in Angular for sure. use import cv from "@techstark/opencv-js" then you can call method on cv.

I have used import cv from "@techstark/opencv-js" on my code in TS file of Angular and got the following error :

ERROR in src/app/core/models/human-face.ts:5:8 - error TS1192: Module '"D:/Z-Face/ZFaceDragDropCanvas/ZFaceSketch/z-face/z-face-client/node_modules/@techstark/opencv-js/dist/types/index"' has no default export.

The command import cv from "@techstark/opencv-js" will work in JavaScript file but not in case of TypeScript (TS) file though.

When I change to import {cv} from "@techstark/opencv-js"to be in line with the library import convention of TypeScript (TS) file and Angular10, I got the following error instead:

error TS2724: Module '"../../../../node_modules/@techstark/opencv-js/dist/types"' has no exported member 'cv'. Did you mean 'CV'? import { cv } from "@techstark/opencv-js"

The way to make it works is to set the import as follows: import { CV as cv } from "@techstark/opencv-js"

More will follow soon.

ttt43ttt commented 2 years ago

See https://github.com/TechStark/opencv-js-examples/blob/develop/opencv-js-angular-example/src/app/app.component.ts