-
Notifications
You must be signed in to change notification settings - Fork 0
/
webcam.js
61 lines (51 loc) · 1.43 KB
/
webcam.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var NodeWebcam = require("node-webcam");
var MaxApi = require("max-api");
//Default options
var opts = {
//Picture related
width: 1280,
height: 720,
quality: 100,
// Number of frames to capture
// More the frames, longer it takes to capture
// Use higher framerate for quality. Ex: 60
frames: 60,
//Delay in seconds to take shot
//if the platform supports miliseconds
//use a float (0.1)
//Currently only on windows
delay: 0,
//Save shots in memory
saveShots: true,
// [jpeg, png] support varies
// Webcam.OutputTypes
output: "jpeg",
//Which camera to use
//Use Webcam.list() for results
//false for default device
device: false,
// [location, buffer, base64]
// Webcam.CallbackReturnTypes
callbackReturn: "location",
//Logging
verbose: false
};
//Creates webcam instance
var Webcam = NodeWebcam.create(opts);
//Will automatically append location output type
Webcam.capture("test_picture", function (err, data) { });
//Also available for quick use
NodeWebcam.capture("test_picture", opts, function (err, data) {
});
//Get list of cameras
Webcam.list(function (list) {
//Use another device
var anotherCam = NodeWebcam.create({ device: list[0] });
});
//Return type with base 64 image
var opts = {
callbackReturn: "base64"
};
NodeWebcam.capture("test_picture", opts, function (err, data) {
var image = "<img src='" + data + "'>";
});