Im trying to write a processing script that will randomly cycle through a series of webcams, i can get the values to change of random but it doesn't seem to effect the camera changing. I'm a little stuck so any help is appreciated.
import processing.video.*;
Capture cam1;
Capture cam2;
void setup() {
size(1000, 1000);
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
for (int i = 0; i < cameras.length; i++) {
println(cameras[i]);
}
// The camera can be initialized directly using an
// element from the array returned by list():
cam1 = new Capture(this, cameras[6]);
println(cameras[3]);
cam2 = new Capture(this, cameras[18]);
println(cameras[18]);
}
}
void draw() {
if (cam1.available() == true) {
cam1.read();
}
if (cam2.available() == true) {
cam2.read();
}
image(cam1, 0, 0);
image(cam2, 320, 0);
image(cam1, 0, 200);
image(cam2, 320, 200);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
int random = int(random(2));
println(random);
randomCamera(random);
}
void randomCamera(int rand){
switch(rand) {
case 0:
cam1.start();
cam2.stop();
break;
case 1:
cam2.start();
cam1.stop();
break;
default: // Default executes if the case labels
println("None"); // don't match the switch parameter
I currently have a sketch here, that runs a video in a circle that follows the mouse. I would like to get it so that the video changes when a button is pressed.
I have it that the video changes while one is holding the button, but i want one press to equal a sort of "play" button, i will have multiple buttons all wired to a different video.
This code also seems to run really slow, any ideas on how to improve that aspect are welcome as well.
Serial myPort; // Create object from Serial class int val; // Data received from the serial port Movie movie1, movie2, middlemovie;
void setup() { size(displayWidth, displayHeight); background(0); frameRate(30); // Load and play the video in a loop movie2 = new Movie(this, "looping_static_1.mov.1"); movie2.loop(); String portName = Serial.list()[0]; myPort = new Serial(this, portName, 9600); }
void movieEvent(Movie m) { m.read(); }
void draw(){ if ( myPort.available() > 0) { // If data is available, val = myPort.read(); // read it and store it in val } if (val == 0) { // If the serial value is 0, movie1 = new Movie(this, "transit.mov"); movie1.loop(); } else { movie1 = new Movie(this, "looping_static_1.mov.1"); movie1.loop(); } float solidRadius = 160.0; // radius of solid circle. float radius = 200.0; // radius of the fading circle. movie1.read(); movie2.read(); // movie1.loadPixels(); image(movie2, 0,0); loadPixels(); for (int x = mouseX-int(radius); x <= mouseX+int(radius); x++ ) { for (int y = mouseY-int(radius); y <= mouseY+int(radius); y++ ) { if( y < 0 || y >= height || x < 0 || x >= width ){ continue; } int loc = x + y*width; // if this next line gives you issues, use the commented out one below it instead. color val = movie1.get(x,y); // color val = movie1.pixels[loc]; // And also uncomment the line "movie1.loadPixels();", above. float distance = dist(x,y,mouseX,mouseY); float transparency = map(radius-(distance-solidRadius), solidRadius, radius, 0.0, 255.0); color c = color(red(val), green(val), blue(val), transparency ); pixels[loc] = distance<radius?blendColor(pixels[loc],c,BLEND):pixels[loc]; pixels[loc] = distance<solidRadius?val:pixels[loc]; } } updatePixels(); }
trying to run the example sketch in linux but i keep getting the following error:
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Unable to load library 'gstinterfaces-0.10': libgstinterfaces-0.10.so: cannot open shared object file: No such file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:379)
at org.gstreamer.lowlevel.GNative.loadNativeLibrary(Unknown Source)
at org.gstreamer.lowlevel.GNative.loadLibrary(Unknown Source)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstColorBalanceAPI.<clinit>(GstColorBalanceAPI.java:30)
at org.gstreamer.lowlevel.GstTypes$StaticData$1.<init>(GstTypes.java:171)
at org.gstreamer.lowlevel.GstTypes$StaticData.<clinit>(GstTypes.java:168)
at org.gstreamer.lowlevel.GstTypes.getTypeMap(GstTypes.java:117)
at org.gstreamer.lowlevel.GstTypes.classFor(GstTypes.java:95)
at org.gstreamer.lowlevel.NativeObject.classFor(NativeObject.java:210)
at org.gstreamer.lowlevel.NativeObject.objectFor(NativeObject.java:187)
at org.gstreamer.lowlevel.NativeObject.objectFor(NativeObject.java:164)
at org.gstreamer.lowlevel.NativeObject.objectFor(NativeObject.java:161)
at org.gstreamer.lowlevel.NativeObject.objectFor(NativeObject.java:158)
at org.gstreamer.ElementFactory.elementFor(ElementFactory.java:230)
at org.gstreamer.ElementFactory.make(ElementFactory.java:211)
what do i have to install to get rid of the error?