HTML5 webcam streaming javascript library, with front and back camera switch, also have take photo function.
npm install webcam-easy-v2
$ npm login --registry=https://npm.pkg.github.com
> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS
`
3. Use `npm run release -- -p 'notes'` (-p patch, -m minor, -M major) to re-build and publish the code to repository, this will automatically increase version and tag it in Github repository.
How to npm install github package manager
1. Add `.npmrc` file to your package root folder and add this line
`
@adapterdigital:registry=https://npm.pkg.github.com/adapterdigital
`
2. You can now use `npm i @adapterdigital/package-name`
Build
This will build and copy /dist files and copy it to ../vue3-camera-lab/src/lib for testing purpose
` shell
npm run build
`
Release
Publish to npm
#### MAC
` shell
#patch version increase
npm run release -- -p 'comment'
#minor version increase
npm run release -- -m 'comment'
#Major version increase
npm run release -- -M 'comment'
`
#### WINDOWS
` shell
#patch version increase
npm run win-release -- -p 'comment'
#minor version increase
npm run win-release -- -m 'comment'
#Major version increase
npm run win-release -- -M 'comment'
`
Installation
#### Use Git Clone
` shell
git https://github.com/adapterdigital/webcam-easy-v2.git
`
#### OR Use NPM
` shell
npm install @adapterdigital/webcam-easy-v2
`
Usage
#### 1. Import into javascript
` js
//Flippable
import {FlippableWebCamera} from '@adapterdigital/webcam-easy-v2';
//User
import {UserWebCamera} from '@adapterdigital/webcam-easy-v2';
`
#### 2. Place elements in HTML
`html
`
#### 3. Call constructor in javascript
` js
const webcamElement = document.getElementById('webcam');
const canvasElement = document.getElementById('canvas');
const snapSoundElement = document.getElementById('snapSound');
//flippable
const webcam = new FlippableWebCamera(webcamElement, 'user', canvasElement, snapSoundElement);
//user
const webcam = new UserWebCamera(webcamElement, true, canvasElement, snapSoundElement);
//bind this to UI (Only Flippable)
function cameraFilp() {
if(webcamDom.webcamCount > 1){
await webcamDom.flip();
}
}
`
#### 4. Start Webcam
` js
webcam.start()
.then(result =>{
console.log("webcam started");
})
.catch(err => {
console.log(err);
if (err.message && err.message.toLowerCase().indexOf("not supported browser") !== -1) {
// check ios / android here!
alert(err.toString());
} else {
// user denied or no matched media
}
});
//or
try {
await webcam.start();
console.log("webcam started");
} catch(err) {
console.log(err);
if (err.message && err.message.toLowerCase().indexOf("not supported browser") !== -1) {
// check ios / android here!
alert(err.toString());
} else {
// user denied or no matched media
}
}
`
#### 5. Take Photo
` js
var picture = webcam.snap();
//or
var picture = webcam.snap(0.3);//0.3 Mega pixel snap!!
var picture = webcam.snap(8);//8 Mega pixel snap!!
`
#### 6. Stop Webcam
` js
webcam.stop();
``