I am getting an uncaught promise error from the following code. Does anyone have an idea how should I resolve this error?
Error:
(index):87 Uncaught (in promise) 1073690080
detectFrame @ (index):87
requestAnimationFrame (async)
detectFrame @ (index):86
requestAnimationFrame (async)
Code:
function detectObjects(video, model, canvas)
{
const context = canvas.getContext('2d');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
async function detectFrame()
{
context.clearRect(0, 0, canvas.width, canvas.height);
context.drawImage(video, 0, 0, canvas.width, canvas.height);
var img = cv.imread(canvas);
//console.log("detect frame trigger");
//Opencv code here
requestAnimationFrame(detectFrame);
}
detectFrame();
}
async function main() {
await loadOpencv();
const video = await setupCamera();
const model = await loadModel();
const canvas = document.getElementById('canvas');
detectObjects(video, model, canvas);
}
I have tried adding Promise to requentAnimation function but I am not able solve it.
New contributor
Neil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.