
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
face-detector-lite
Advanced tools
基于 TensorFlow.js 与 BlazeFace 的轻量级浏览器人脸检测库,默认内置模型与依赖,适用于现代 Web 项目与 Vue 3。
浏览器端实时检测演示界面
npm install face-detector-lite<script src="https://cdn.jsdelivr.net/npm/face-detector-lite/dist/face-detector.standalone.min.js"></script>
<script>
const detector = new FaceDetector({ showVideo: true })
.onFaceDetected(() => console.log('检测到人脸'))
.onNoFace(() => console.log('未检测到人脸'));
await detector.initialize();
detector.startDetection();
</script>
<script type="module">
import FaceDetector from 'https://cdn.jsdelivr.net/npm/face-detector-lite/+esm';
const detector = new FaceDetector({ showVideo: true });
await detector.initialize();
detector.startDetection();
</script>
npm install face-detector-lite
import FaceDetector from 'face-detector-lite';
const detector = new FaceDetector({
showVideo: true,
// libUrls: { tf: '/node_modules/face-detector-lite/libs/tf.min.js', blazeface: '/node_modules/face-detector-lite/libs/blazeface.js' },
// modelUrl: '/node_modules/face-detector-lite/models/blazeface/model.json'
});
await detector.initialize();
detector.startDetection();
默认
offlineOnly = true。若希望自动回落到 CDN,可显式设置offlineOnly: false。
import { FaceDetectorView } from 'face-detector-lite/vue';
// 或 import FaceDetectorPlugin from 'face-detector-lite/vue';
// app.use(FaceDetectorPlugin);
<template>
<FaceDetectorView
class="preview"
@initialized="onReady"
@detected="onDetected"
@no-face="onNoFace"
@error="onError"
/>
</template>
组件默认会隐藏视频 (
show-video=false)、渲染一个占位容器 (render-container=true),并在挂载完成后自动开始检测 (start-on-mounted=true)。
如需自定义行为,可传入对应属性:
<FaceDetectorView
:show-video="true"
:render-container="false"
:start-on-mounted="false"
:interval="150"
:camera="{ facingMode: 'environment', width: 1280, height: 720 }"
@initialized="onReady"
@detected="onDetected"
@no-face="onNoFace"
@error="onError"
/>
new FaceDetector(options?)
常用配置
showVideo:是否渲染摄像头画面,默认 false。videoContainer:自定义视频容器,可为选择器或 DOM 实例。interval:检测间隔(毫秒),默认 100。modelUrl:自定义模型地址,默认加载内置模型。libUrls:自定义 TF.js / BlazeFace 资源路径。offlineOnly:是否禁止访问 CDN,默认 true。camera:摄像头参数 { facingMode, width, height }。实例方法
initialize():初始化摄像头与模型。startDetection() / stopDetection():开始或停止检测。detectFace():执行一次检测,返回是否识别到人脸。destroy():释放摄像头与模型资源。事件链式调用
onInitialized(fn)、onFaceDetected(fn)、onNoFace(fn)、onError(fn)。libs/ 与 models/ 资源;可改写 libUrls、modelUrl 指向自托管路径。dist/face-detector.standalone.min.js 已自带所有依赖,直接插入 <script> 即可。offlineOnly = true,包内资源会本地加载;缺失时会抛错,以免静默访问外部网络。npm run version:patch|minor|major 更新版本,再运行 npm run release 发布。window 或 navigator。npm install
npm run build
构建产物位于 dist/,其中 face-detector.standalone.min.js 为自包含版本。
MIT License © DouDOU-start
FAQs
Lightweight browser face detector (TF.js + BlazeFace) with Vue 3 support
We found that face-detector-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.