Object recognition from the camera
This will be a change that involves a couple of steps. First, we’ll introduce a component that can capture video from the browser. We’ll create a CameraDetect.vue
component in the ./components
folder: https://github.com/PacktPublishing/Building-Real-world-Web-Applications-with-Vue.js-3/blob/main/09.tensorflow/.notes/9.13-CameraDetect.vue.
The code in the CameraDetect.vue
component uses composables from the @vueuse
package to interact with the browsers’ Devices
and userMedia
APIs. We’re using useDevicesList
to list the available cameras (lines 33–40) and populate a <v-select />
component (lines 4–14). This allows the user to switch between available cameras.
The user needs to manually activate a camera (also when switching between cameras) for security reasons. The button in the component toggles the camera stream (lines 44–46). To display the stream, we use watchEffect
to pipe the stream...