Gathering detailed insights and metrics for simple-vue-camera
Gathering detailed insights and metrics for simple-vue-camera
Gathering detailed insights and metrics for simple-vue-camera
Gathering detailed insights and metrics for simple-vue-camera
vue-camera-lib
Simple library for Vue.js 3. Display the camera's output or take a photo from the mobile camera/webcam.
vue-camera-lib-2
Simple library for Vue.js 3. Display the camera's output or take a photo from the mobile camera/webcam.
vue-cam
Intented to be a simple camera component for VueJS.
A simple to use, but extensive, camera component for Vue 3 with Typescript support to create great camera experiences.
npm install simple-vue-camera
Typescript
Module System
Node Version
NPM Version
v1.1.3: change camera function now waits for camera to restart
Updated on Dec 08, 2022
v1.1.2: Inline video prop
Updated on Sep 07, 2022
v1.1.1: Error event
Updated on May 24, 2022
v1.1.0: Retrieve currently used device id
Updated on Apr 11, 2022
v1.0.2: Bugfixes and updated README
Updated on Aug 23, 2021
v1.0.1: Release
Updated on Aug 15, 2021
Vue (77.07%)
JavaScript (13.88%)
HTML (6.01%)
TypeScript (3.03%)
Total Downloads
260,317
Last Day
348
Last Week
2,018
Last Month
9,214
Last Year
112,415
MIT License
76 Stars
71 Commits
18 Forks
2 Watchers
1 Branches
5 Contributors
Updated on Mar 27, 2025
Minified
Minified + Gzipped
Latest Version
1.1.3
Package Id
simple-vue-camera@1.1.3
Unpacked Size
28.03 kB
Size
7.91 kB
File Count
9
NPM Version
6.14.12
Node Version
10.24.1
Cumulative downloads
Total Downloads
Last Day
21.3%
348
Compared to previous day
Last Week
-19%
2,018
Compared to previous week
Last Month
-20.4%
9,214
Compared to previous month
Last Year
-0.3%
112,415
Compared to previous year
28
A simple to use, but extensive, camera component for Vue 3 with Typescript support to create great camera experiences like this:
By default, this component does not render any UI elements on top of the video feed, so you can style it and make it your own.
Install Simple Vue Camera with NPM:
npm install simple-vue-camera
or, with Yarn:
yarn install simple-vue-camera
After installation, you can register the Camera
component globally in main.ts
:
1import { createApp } from "vue"; 2import App from "./App.vue"; 3import Camera from "simple-vue-camera"; 4 5createApp(App).component("camera", Camera).mount("#app");
or, register it to a specific component:
1<script lang="ts"> 2import { defineComponent } from "vue"; 3import Camera from "simple-vue-camera"; 4 5export default defineComponent({ 6 components: { 7 Camera, 8 }, 9});
After registering the Camera
component, you can use it as follows:
1<template> 2 <camera :resolution="{ width: 375, height: 812 }" autoplay></camera> 3</template>
Use the available slot to overlay UI on top of the video feed:
1<template> 2 <camera :resolution="{ width: 375, height: 812 }" autoplay> 3 <button>I'm on top of the video</button> 4 </camera> 5</template>
To create screenshots of the video feed, use the snapshot
function on the component reference:
1<template> 2 <camera :resolution="{ width: 375, height: 812 }" ref="camera" autoplay></camera> 3 <button @click="snapshot">Create snapshot</button> 4</template> 5 6<script lang="ts"> 7import Camera from "simple-vue-camera"; 8 9export default defineComponent({ 10 setup() { 11 // Get a reference of the component 12 const camera = ref<InstanceType<typeof Camera>>(); 13 14 // Use camera reference to call functions 15 const snapshot = async () => { 16 const blob = await camera.value?.snapshot(); 17 18 // To show the screenshot with an image tag, create a url 19 const url = URL.createObjectURL(blob); 20 } 21 22 return { 23 camera, 24 snapshot 25 } 26 } 27});
By default, when creating a snapshot, the resolution of the snapshot will be the same as the resolution of the camera feed. To change that, pass a Resolution
with the function call:
1const blob = await camera.value?.snapshot({ width: 1920, height: 1080 });
Or change the image type and quality:
1const blob = await camera.value?.snapshot( 2 { width: 1920, height: 1080 }, 3 "image/png", 4 0.5 5);
It is possible to change the camera. First request all videoinput
devices:
1const devices = camera.value?.devices(["videoinput"]);
Pick a device, e.g. with a dropdown, and pass the device ID to the changeCamera
function:
1const device = devices[0]; 2camera.value?.changeCamera(device.deviceId);
Note: When switching cameras, the camera component will restart and emit the loading
and started
events again.
Name | Type | Default | Description |
---|---|---|---|
resolution | Resolution | 1920 x 1080 | The resolution of the camera view |
facingMode | string | environment | |
autoplay | boolean | true | Determines if the camera is automatically started when mounted, when set to false, you must start the camera programmatically |
playsinline | boolean | true | Determines if the camera plays inline instead of starting full screen, when set to false some browsers open a fullscreen video player |
constraints | MediaStreamConstraints | Change the default constraints |
Name | Parameters | Description |
---|---|---|
devices | kinds: MediaDeviceKind[] | Returns a list of compatible devices which matches the allowed kinds |
start | Starts the camera | |
stop | Stops the camera | |
pause | Pauses the video stream | |
resume | Resumes the video stream | |
changeCamera | deviceID: string | Changes the selected camera |
snapshot | resolution: Resolution , type: string , quality: number | Creates a snapshot of the current video image |
currentDeviceID | Returns the currently used device id of the mediastream |
The Camera
component emits 7 different events.
1<template> 2 <camera 3 @loading="loading" 4 @started="started" 5 @stopped="stopped" 6 @paused="paused" 7 @resumed="resumed" 8 @camera-change="cameraChange" 9 @snapshot="snapshot" 10 @error="error" 11 ></camera> 12</template> 13 14<script lang="ts"> 15import Camera from "simple-vue-camera"; 16 17export default defineComponent({ 18 setup() { 19 const loading = () => console.log("Camera is loading and will start any second"); 20 const started = () => console.log("Camera has started"); 21 const stopped = () => console.log("Camera has stopped"); 22 const paused = () => console.log("Video feed has paused"); 23 const resumed = () => console.log("Video feed has resumed"); 24 const cameraChange = (deviceID: string) => console.log(`Camera has been changed to ${deviceID}`); 25 const snapshot = (blob: Blob) => console.log("A snapshot has been taken"); 26 const error = (error: Error) => console.log("error"); 27 28 return { 29 loading, 30 started, 31 stopped, 32 paused, 33 resumed, 34 cameraChange, 35 snapshot, 36 error 37 } 38 } 39});
Name | Parameters | Description |
---|---|---|
loading | Emitted when the camera is loading | |
started | Emitted when the camera is loaded and is visible | |
stopped | Emitted when the camera has stopped | |
paused | Emitted when the video has paused | |
resumed | Emitted when the video has resumed | |
camera-change | deviceID: string | Emitted when a camera change occurs |
snapshot | blob: Blob | Emitted when a snapshot is taken |
error | error: Error | Emitted when an error occurs |
simple-vue-camera is available under the MIT licence. See the LICENCE for more info.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 4/18 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
54 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More