43 lines
798 B
Markdown
43 lines
798 B
Markdown
# @yizhi/opencv
|
||
|
||
简单的OpenCV封装
|
||
|
||
## 编译源码(可选)
|
||
1. 依赖
|
||
1. python3
|
||
1. cmake
|
||
1. ninja
|
||
1. c++编译器(gcc,clang,Visual Studio ...)
|
||
|
||
1. 编译OpenCV
|
||
```bash
|
||
node thirdpart/install.js --with-opencv
|
||
```
|
||
1. 编译本模块
|
||
```bash
|
||
cmake -B build -G Ninja . -DCMAKE_BUILD_TYPE=Release
|
||
cmake --build build --config Release
|
||
```
|
||
|
||
## 安装
|
||
```bash
|
||
npm install @yizhi/opencv
|
||
```
|
||
|
||
## 使用
|
||
```typescript
|
||
//导入opencv
|
||
import cv from '@yizhi/opencv';
|
||
|
||
//配置addon路径
|
||
cv.config("ADDON_PATH", "/path/to/cv.node");
|
||
//下载addon(可选)
|
||
// 如果配置了ADDON_PATH,则下载addon到ADDON_PATH,否则下载到build/cv.node
|
||
await cv.downloadAddon();
|
||
|
||
//正常使用
|
||
const im = cv.imread("/path/to/input");
|
||
cv.resize(im, 640, 640);
|
||
cv.imwrite("/path/to/output", im);
|
||
```
|