Skip to content

Instantly share code, notes, and snippets.

@dalequark
Last active June 18, 2021 23:34
Show Gist options
  • Save dalequark/c0e9c83e338508a96cc9c12d8d30daf5 to your computer and use it in GitHub Desktop.
Save dalequark/c0e9c83e338508a96cc9c12d8d30daf5 to your computer and use it in GitHub Desktop.
Webcam object detection
<!-- Load TensorFlow.js. This is required to use coco-ssd model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"> </script>
<!-- Load the coco-ssd model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/coco-ssd"> </script>
<script>
// Grab DOM reference to video element.
const video = document.getElementById('webcamVideo');
// Load the model.
cocoSsd.load().then(model => {
// detect objects in the image frame.
model.detect(video).then(predictions => {
console.log('Predictions: ', predictions);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment