November 2019
Intermediate to advanced
296 pages
7h 52m
English
One of the biggest benefits of using TensorFlow.js is that we can use a web browser as a data source. Most web browsers support API to manipulate webcams. tfjs-data implements an instinctive wrapper to access the webcam, tf.data.webcam:
import * as tf from '@tensorflow/tfjs';async function webcamLaunch() { const display = document.getElementById('display'); const videoElement = document.createElement('video'); // Add element to display the webcam image. display.appendChild(videoElement); videoElement.width = 500; videoElement.height = 500; const webcamIterator = await tf.data.webcam(videoElement); // img is a tensor showing the input webcam image. const img = await webcamIterator.capture(); img.print();}webcamLaunch();
This API builds ...
Read now
Unlock full access