@opencvjs/web 4.10.0-release.2 → 4.10.0-release.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -33
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,49 +10,24 @@ npm install @opencvjs/web
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
`@opencvjs/web` exports a `
|
|
13
|
+
`@opencvjs/web` exports a `loadOpenCV` function that returns a Promise that resolves to the OpenCV.js API.
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import {
|
|
16
|
+
import { loadOpenCV } from "@opencvjs/web";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const cv = await load();
|
|
21
|
-
|
|
22
|
-
const imgSrc = document.getElementById("img_src");
|
|
23
|
-
const imgDst = document.getElementById("img_dst");
|
|
24
|
-
|
|
25
|
-
// Wait for the image to load
|
|
26
|
-
await imgSrc.decode();
|
|
27
|
-
|
|
28
|
-
// Read the image
|
|
29
|
-
let src = cv.imread(imgSrc);
|
|
30
|
-
|
|
31
|
-
// Convert the image to grayscale
|
|
32
|
-
let dst = new cv.Mat();
|
|
33
|
-
cv.cvtColor(src, dst, cv.COLOR_RGBA2GRAY, 0);
|
|
34
|
-
|
|
35
|
-
// Show the grayscale image
|
|
36
|
-
cv.imshow(imgDst, dst);
|
|
37
|
-
|
|
38
|
-
// Release the memory
|
|
39
|
-
src.delete();
|
|
40
|
-
dst.delete();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
main();
|
|
18
|
+
const cv = await loadOpenCV();
|
|
19
|
+
const mat = new cv.Mat();
|
|
44
20
|
```
|
|
45
21
|
|
|
46
22
|
## TypeScript
|
|
47
23
|
|
|
48
|
-
`@opencvjs/web` exports a type
|
|
24
|
+
`@opencvjs/web` exports a type `OpenCV` for the OpenCV.js API.
|
|
49
25
|
|
|
50
26
|
```ts
|
|
51
|
-
import type
|
|
52
|
-
import { load } from "@opencvjs/web";
|
|
27
|
+
import { loadOpenCV, type OpenCV } from "@opencvjs/web";
|
|
53
28
|
|
|
54
|
-
const cv = await
|
|
55
|
-
const
|
|
29
|
+
const cv: typeof OpenCV = await loadOpenCV();
|
|
30
|
+
const mat: OpenCV.Mat = new cv.Mat();
|
|
56
31
|
```
|
|
57
32
|
|
|
58
33
|
## Example
|
package/lib/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { OpenCV } from "@opencvjs/types";
|
|
|
4
4
|
* Compile the WASM library and return a promise that resolves to the
|
|
5
5
|
* OpenCV.js library.
|
|
6
6
|
*/
|
|
7
|
-
declare function
|
|
7
|
+
declare function loadOpenCV(): Promise<typeof OpenCV>;
|
|
8
8
|
|
|
9
9
|
export type { OpenCV };
|
|
10
|
-
export {
|
|
10
|
+
export { loadOpenCV };
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencvjs/web",
|
|
3
|
-
"version": "4.10.0-release.
|
|
3
|
+
"version": "4.10.0-release.4",
|
|
4
4
|
"author": "ocavue <ocavue@gmail.com>",
|
|
5
5
|
"repository": "https://github.com/ocavue/opencvjs",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"typescript": "^5.6.3"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@opencvjs/types": "4.10.0-release.
|
|
14
|
+
"@opencvjs/types": "4.10.0-release.3"
|
|
15
15
|
},
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"publishConfig": {
|