You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
629 B

import { onMounted, ref } from 'vue';
import { Detector } from './hand_landmark/detector';
const videoRef = ref<HTMLVideoElement | null>(null);
const detector = new Detector();
onMounted(async () => {
await detector.initialize(); // 初始化模型
const video = videoRef.value!;
video.width = 640;
video.height = 480;
navigator.mediaDevices.getUserMedia({ video: true }).then((stream) => {
video.srcObject = stream;
video.play();
// 每隔 200ms 检测一帧
setInterval(async () => {
const result = await detector.detect(video);
await detector.process(result);
}, 200);
});
});