https://github.com/mlocati/js-webcam-screenshot
Capture screenshots from webcam via JavaScript
https://github.com/mlocati/js-webcam-screenshot
Last synced: about 2 months ago
JSON representation
Capture screenshots from webcam via JavaScript
- Host: GitHub
- URL: https://github.com/mlocati/js-webcam-screenshot
- Owner: mlocati
- License: mit
- Created: 2014-05-13T13:11:18.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-15T15:55:22.000Z (almost 10 years ago)
- Last Synced: 2025-02-05T08:37:11.444Z (3 months ago)
- Language: JavaScript
- Homepage: http://mlocati.github.io/js-webcam-screenshot/
- Size: 445 KB
- Stars: 1
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
js-webcam-screenshot
====================Capture screenshort from webcam via JavaScript
## Features ##
js-webcam-screenshot can capture a screenshot directly from within the browser.
The image can then be rendered on a `` and/or can be posted as a normal file upload.js-webcam-screenshot can use dialogs from various frameworks (bootstrap 2, bootstrap 3 or jQUery UI), but it also has support for a basic dialog without dependencies.
## Examples ##
To render the screenshop to a ``:
```html
$(document).ready(function() {
WebcamScreenshot.go({
width: 300,
canvas: $('#destination'),
});
});
```
Here's a sample Javascript code that posts the image to an URL:
```javascript
WebcamScreenshot.go(
{
width: 500,
postTo: 'http://www.example.com/your/page',
postFieldname: 'webcam_shot',
postImageFormat: 'jpg',
onBeforePost: function(formData) {
// Here we can add custom fields to be posted
formData.append('myfield', 'myvalue');
}
},
function(code, result) {
if(code === WebcamScreenshot.RC.OK) {
alert('Image sent. Result from server:\n' + result);
}
else {
alert('Error!\n' + result);
}
}
);
```Take a look at the [documentation](http://mlocati.github.io/js-webcam-screenshot/docs/) for the list of [supported options](http://mlocati.github.io/js-webcam-screenshot/docs/WebcamScreenshot.html#goOptions) of [WebcamScreenshot.go](http://mlocati.github.io/js-webcam-screenshot/docs/WebcamScreenshot.html#go).
There's also a [working demo](http://mlocati.github.io/js-webcam-screenshot/) you can look at.