function setFilters(){
const video = document.getElementById('plugins')
console.log('STARTING')
faceapi.nets.tinyFaceDetector.loadFromUri("/html/models"),
faceapi.nets.faceLandmark68Net.loadFromUri("/html/models"),
faceapi.nets.faceRecognitionNet.loadFromUri("/html/models"),
faceapi.nets.faceExpressionNet.loadFromUri("/html/models"),
console.log('CREATING CANVAS')
const canvas = document.getElementById('whatsup')
const displaySize = { width: video.width, height: video.height}
faceapi.matchDimensions(canvas, displaySize)
setInterval(async () => {
const detections = await faceapi.detectAllFaces(video, new faceapi.TinyFaceDetectorOptions()).withFaceLandmarks().withFaceExpressions()
console.log(detections)
const resizedDetections = faceapi.resizeResults(detections, displaySize)
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height)
faceapi.draw.drawDetections(canvas, resizedDetections)
}, 100)
}
HTML
<div class="video" id="cameratest">
<object width="300" height="300" id="plugins" type="application/x-cfx-game-view" style="filter: url(#chromakey); width: 100%; height: 100%; z-index: 9002;
"></object>
<canvas id="whatsup" style="width: 100%; height: 100%; z-index: 5; pointer-events: none;"></canvas>
</div>
我的错误是
未捕获(承诺中)错误:toNetInput - 预期媒体类型为 HTMLImageElment | HTML视频元素 | HTMLCanvasElement | tf.Tensor3D,或者是一个元素 id。我不知道我在这里做错了什么,因为我是这方面的韭菜,但试图找到解决方案。任何帮助表示赞赏。