-
Notifications
You must be signed in to change notification settings - Fork 0
/
LiveClip.pde
executable file
·86 lines (71 loc) · 2.16 KB
/
LiveClip.pde
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
79
80
81
82
83
84
85
86
import processing.video.*;
class LiveClip extends SilhouetteClip {
LiveClip(SilhouetteClipInfo clipInfo)
{
super();
this.clipInfo = clipInfo;
this.crossfade = clipInfo.crossfade;
boolean liveSilhouette = Utils.isLiveFilename(clipInfo.silhouetteFilename);
if(Utils.isValidFilename(clipInfo.silhouetteFilename) && !liveSilhouette) {
silhouetteMovie = loadMovie(clipInfo.silhouetteFilename);
} else if(liveSilhouette) {
silhouetteCapture = getCaptureDevice();
}
boolean liveBackground = Utils.isLiveFilename(clipInfo.backgroundFilename);
if(Utils.isValidFilename(clipInfo.backgroundFilename) && !liveBackground) {
backgroundMovie = loadMovie(clipInfo.backgroundFilename);
} else if(liveBackground) {
backgroundCapture = getCaptureDevice();
}
filename = "Live Stream";
setDuration(clipInfo.duration);
}
boolean isLiveSilhouette() {
return silhouetteCapture != null;
}
boolean isLiveBackground() {
return backgroundCapture != null;
}
int getSilhouetteFrameLength() {
if(isLiveSilhouette()) {
return silhouetteCapture.pixels.length;
}
return super.getSilhouetteFrameLength();
}
color getSilhouettePixels(int index) {
if(isLiveSilhouette()) {
return silhouetteCapture.pixels[index];
}
return super.getSilhouettePixels(index);
}
int getBackgroundFrameLength() {
if(isLiveBackground()) {
return silhouetteCapture.pixels.length;
}
return super.getBackgroundFrameLength();
}
color getBackgroundPixels(int index) {
if(isLiveBackground()) {
return backgroundCapture.pixels[index];
}
return super.getBackgroundPixels(index);
}
void start() {
if(isLiveSilhouette()) {
silhouetteCapture.start();
} else if(isLiveBackground()) {
backgroundCapture.start();
}
super.start();
}
void stop() {
if(isLiveSilhouette()) {
silhouetteCapture.stop();
} else if(isLiveBackground()) {
backgroundCapture.stop();
}
super.stop();
}
protected Capture silhouetteCapture = null;
protected Capture backgroundCapture = null;
}