-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathInfragram.js
78 lines (69 loc) · 2.59 KB
/
Infragram.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
window.Infragram = function Infragram(options) {
options = options || {};
options.uploader = options.uploader || false;
options.processor = options.processor || 'javascript';
options.camera = require('./io/camera')(options);
options.colorized = options.colorized || false;
options.mode = options.mode || "raw",
options.video_live = options.video_live || false,
options.webGlSupported = options.webGlSupported || false; // move into processor
options.processors = {
'webgl': require('./processors/webgl'),
'javascript': require('./processors/javascript'),
}
options.processor = options.processors[options.processor](options);
options.file = require('./io/file')(options, options.processor);
options.logger = require('./logger')(options);
var Interface = require('./ui/interface')(options); // this can change processor based on URL hash
//options.processor.initialize(options); // double initialize after end of processor code?
console.log('processor:', options.processor.type)
options.colorize = function colorize(map) {
options.processor.colorize(map);
}
// this should accept an object with parameters r,g,b,h,s,v,m and mode
options.run = function run(mode) {
options.logger.save_log();
return options.processor.run(mode);
}
// split into processor.video() methods
options.video = function video() {
options.camera.initialize();
var interval;
if (options.processor.type == "webgl") interval = 15;
else interval = 150;
setInterval(function() {
if (image) options.run(options.mode);
options.camera.getSnapshot();
//if (options.colorized) return options.colorize();
}, interval);
}
options.processLocalVideo = function processLocalVideo() {
options.camera.unInitialize();
var interval;
if (options.processor.type == "webgl") interval = 15;
else interval = 150;
setInterval(function() {
if (image) options.run(options.mode);
options.camera.getSnapshot();
//if (options.colorized) return options.colorize();
}, interval);
}
// TODO: this doesn't work; it just downloads the unmodified image.
// probably a timing issue?
function download() {
//options.run(options.mode);
//if (options.colorized) return options.colorize();
options.file.downloadImage();
}
return {
Camera: options.camera,
Interface: Interface,
logger: options.logger,
run: options.run,
colorize: options.colorize,
processors: options.processors,
download: download,
options: options
}
}
module.exports = Infragram;