//globals | //globals | ||||
uptime = 118948355 | |||||
uptime = 119045247 |
void startWebcam() { | void startWebcam() { | ||||
String[] cameras = Capture.list(); | String[] cameras = Capture.list(); | ||||
println("Hi"); | println("Hi"); | ||||
println(cameras); | |||||
for (int i = 0; i < cameras.length; i++) { | |||||
println(cameras[i]); | |||||
} | |||||
//println(cameras); | |||||
cam.start(); | cam.start(); | ||||
webcamRunning = true; | webcamRunning = true; | ||||
} | } | ||||
class WEBCAM extends Shader { | class WEBCAM extends Shader { | ||||
PImage img; | PImage img; | ||||
int rw, rh, x, y, w, h, croptop, cropbottom, cropleft, cropright, contrast, brightness, hue, saturation; | |||||
int rw, rh, x, y, w, h, croptop, cropbottom, cropleft, cropright, contrast, brightness, hue, saturation, camSelected, camSelectedPrev; | |||||
final int[] blends = {BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN}; | final int[] blends = {BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN}; | ||||
WEBCAM() { | WEBCAM() { | ||||
rw = canvas.width; | rw = canvas.width; | ||||
rh = canvas.height; | rh = canvas.height; | ||||
name = "Webcam"; | name = "Webcam"; | ||||
println(Capture.list().length); | |||||
img = createImage(rw, rh, ARGB); | img = createImage(rw, rh, ARGB); | ||||
if (!webcamRunning) startWebcam(); | if (!webcamRunning) startWebcam(); | ||||
//params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); | //params.add(new Param("mode", INTVAL, 0, 1, new int[]{RANDOM, SQUAR})); | ||||
params.add(new Param("hue", FLOATVAL, 0.0, 1.0, new int[]{TRIANG, SINE, RAMPUPDOWN })); | params.add(new Param("hue", FLOATVAL, 0.0, 1.0, new int[]{TRIANG, SINE, RAMPUPDOWN })); | ||||
params.add(new Param("saturation", FLOATVAL, 0.0, 1.0, new int[]{TRIANG, SINE, RAMPUPDOWN })); | params.add(new Param("saturation", FLOATVAL, 0.0, 1.0, new int[]{TRIANG, SINE, RAMPUPDOWN })); | ||||
params.add(new Param("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM })); | params.add(new Param("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM })); | ||||
params.add(new Param("webcam", INTVAL, 0, Capture.list().length-1, new int[]{TRIANG, SINE, RAMPUPDOWN, })); | |||||
camSelected = (int)params.get(13).value; | |||||
camSelectedPrev = (int)params.get(13).value; | |||||
} | } | ||||
void apply() { | void apply() { | ||||
rw = canvas.width; | rw = canvas.width; | ||||
w = int(params.get(2).value*(rw*2)); | w = int(params.get(2).value*(rw*2)); | ||||
h = int(params.get(3).value*(rh*2)); | h = int(params.get(3).value*(rh*2)); | ||||
if(cam.available()) img = cam.get(); | |||||
camSelected = (int)params.get(13).value; | |||||
/* | |||||
if (camSelected != camSelectedPrev) { | |||||
currentCam = camSelected; | |||||
camSelectedPrev = camSelected; | |||||
stopWebcam(); | |||||
startWebcam(); | |||||
//new Capture(this, 1920,1080, Capture.list()[camSelected]); | |||||
}*/ | |||||
//params.get(13) //camera id | |||||
if (cam.available()) img = cam.get(); | |||||
img = webcamImg.get(); | img = webcamImg.get(); | ||||
canvas.beginDraw(); | canvas.beginDraw(); |
boolean videoRecord = false; | boolean videoRecord = false; | ||||
//boolean webcamMode = false; | //boolean webcamMode = false; | ||||
//Capture[] cams; | |||||
//ArrayList<Capture> cams = new ArrayList<Capture>(); | |||||
Capture cam; | |||||
String[] cameras; | |||||
int currentCam; | |||||
String[] params; | String[] params; | ||||
PImage droppedImage; | PImage droppedImage; | ||||
void dropEvent(DropEvent theDropEvent) { | void dropEvent(DropEvent theDropEvent) { | ||||
sourceManager.importURI(theDropEvent.filePath()); | sourceManager.importURI(theDropEvent.filePath()); | ||||
} | } | ||||
SecondApplet gui; | SecondApplet gui; | ||||
PApplet mainApplet; | PApplet mainApplet; | ||||
void setup() { | void setup() { | ||||
} | } | ||||
fallbackImage = loadImage(dataPath("0.png")); | fallbackImage = loadImage(dataPath("0.png")); | ||||
bin = loadImage(dataPath("bin.png")); | bin = loadImage(dataPath("bin.png")); | ||||
String[] cameras = Capture.list(); | |||||
cameras = Capture.list(); | |||||
/* | |||||
for (int i = 0; i < cameras.length-1; i++) { | |||||
try { | |||||
cams.add(new Capture(this, 1920, 1080, cameras[i])); | |||||
} | |||||
catch(Exception e) { | |||||
println(e); | |||||
} | |||||
} | |||||
*/ | |||||
cam = new Capture(this, 1920,1080, "pipeline:autovideosrc"); | cam = new Capture(this, 1920,1080, "pipeline:autovideosrc"); | ||||
//falls du nicht mit mir in die oper möchtest gehe ich mit pe, sie hat morgen abend keine termine und würde sich natürlich in beiden fällen freuen. von ihr auch noch alles gute zum geburtstag hatte ich vergessen zu sagen. | |||||
//ich bin auch aufgeregt. vielleicht doch lieber mit dem zug. einfach versuchen sich einfach was zu gönnen. zu deinem schwarzen kleid ziehe ich | |||||
//cam = new Capture(this, 1920,1080, "Video Assist 5\" 3G"); | |||||
OS = getOS(); | OS = getOS(); | ||||
String[] args = {"SecondFrame"}; | String[] args = {"SecondFrame"}; | ||||
PImage webcamImg; | PImage webcamImg; | ||||
void captureEvent(Capture c) { | void captureEvent(Capture c) { | ||||
c.read(); | c.read(); | ||||
Capture cam = cams.get(currentCam); | |||||
webcamImg = cam.get(); | webcamImg = cam.get(); | ||||
} | } | ||||
fill(#ff0000); | fill(#ff0000); | ||||
ellipse(width-100, height-100, 30, 30); | ellipse(width-100, height-100, 30, 30); | ||||
} | } | ||||
if (recording) { | if (recording) { |
/* webcam = cp5.addToggle("webcam") | |||||
.setPosition(100, height-65) | |||||
.setSize(12, 12) | |||||
.setValue(false) | |||||
.plugTo(this, "CP5_webcamAction"); | |||||
webcam.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);*/ | |||||
/* webcam = cp5.addToggle("webcam") | |||||
.setPosition(100, height-65) | |||||
.setSize(12, 12) | |||||
.setValue(false) | |||||
.plugTo(this, "CP5_webcamAction"); | |||||
webcam.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);*/ | |||||
Toggle robot = cp5.addToggle("autoPlay") | Toggle robot = cp5.addToggle("autoPlay") | ||||
.setPosition(100, height-50) | .setPosition(100, height-50) | ||||
startRobot = true; | startRobot = true; | ||||
autoPlay = !autoPlay; | autoPlay = !autoPlay; | ||||
} | } | ||||
/* | |||||
/* | |||||
void CP5_webcamAction() { | void CP5_webcamAction() { | ||||
webcamMode = !webcamMode; | |||||
if (webcamMode) sourceManager.startWebcam(); | |||||
else { | |||||
sourceManager.stopWebcam(); | |||||
source = null; //to trigger auto-fallback next frame | |||||
} | |||||
} | |||||
*/ | |||||
webcamMode = !webcamMode; | |||||
if (webcamMode) sourceManager.startWebcam(); | |||||
else { | |||||
sourceManager.stopWebcam(); | |||||
source = null; //to trigger auto-fallback next frame | |||||
} | |||||
} | |||||
*/ | |||||
void CP5_nativeResoAction() { | void CP5_nativeResoAction() { | ||||
renderSize = max(nativeResoX, nativeResoY); | renderSize = max(nativeResoX, nativeResoY); | ||||
//renderer.setSize(nativeResoX, nativeResoY); | //renderer.setSize(nativeResoX, nativeResoY); | ||||
if (random(1)<0.01) { | if (random(1)<0.01) { | ||||
int removeMe = int(random(shaderList.size()-1)); | int removeMe = int(random(shaderList.size()-1)); | ||||
println("removing" + removeMe); | |||||
bricks.get(removeMe).press(); | |||||
shaderManager.removeShader(removeMe); | |||||
pressedBrick = -1; | |||||
if ((removeMe == 0 && bricks.get(removeMe).name.equals("Webcam")) == false) { | |||||
println(bricks.get(removeMe).name); | |||||
println("removing" + removeMe); | |||||
bricks.get(removeMe).press(); | |||||
shaderManager.removeShader(removeMe); | |||||
pressedBrick = -1; | |||||
} | |||||
} | } | ||||
} | } | ||||
Capture cam; | |||||
Movie movie; | Movie movie; | ||||
boolean moviePlaying, imageChanged; | boolean moviePlaying, imageChanged; | ||||
PImage fallbackImage; | PImage fallbackImage; |