# 安装

```
npm i @faceunity/virtualcamera
```

# ！！注意

目前本项目仅支持windows平台

# 使用

1. 注册虚拟摄像头SDK，由于需要管理员权限执行，注册时会弹出确认弹窗，确认后注册成功，注册过一次后无需再注册(重复注册也是允许的)

```
import { registeVirturalCamera } from 'virtualcamera'
registeVirturalCamera().then(()=>{
    console.log('注册成功');
})
```

2. 创建摄像头并推送数据

```
import { setTimeout } from "timers/promises";
import { CameraType, changeResolutionOfVirturalCamera, createVirturalCamera, pushDataToVirturalCamera } from "@faceunity/virtualcamera";

createVirturalCamera(CameraType.RGBA, 640, 480);
const buf = Buffer.from(new Array(640 * 480 * 4));
(async () => {
    // changeResolutionOfVirturalCamera(720, 480); //需要动态修改摄像头分辨率时可以使用该接口
    while (1) {
        await setTimeout(100);
        pushDataToVirturalCamera(buf, 640, 480);
    }
})()
```