Search code examples
javascripttensorflowhtml5-videotensorflow.js

tensorflow.data.webcam(): "Uncaught (in promise) TypeError: Cannot set property message of which has only a getter"


I am using TensorFlow.js in my web application and the input is a camera. In particular, I am using MobileNet to classifying the camera input. This tutorial is an inspiration for this app. There is a video object:

<video autoplay playsinline muted id="webcam" width="224" height="224"></video>

And I access it in my JavaScript file:

const webcamElement = document.getElementById('webcam');

And take an image from the video object, convert it into a tensor to later preprocess and predict using the frame:

const webcam = await tf.data.webcam(webcamElement);

However, when I run the last line above, it results in the following error: Error Message

Am I doing something wrong? I tried to run the tutorial which also used tf.data.webcam() and it worked ok.


Solution

  • This error disappeared when I restarted my computer and reloaded the webpage.