Files
opencv/README.md
2025-03-17 11:51:23 +08:00

43 lines
798 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# @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);
```