Hello,
For my school project I need to create an exhibition. My exhibition is about spinal hernia. I want my visitors to see themself lifting up a box(a light one) in the correct way. If they lift it the wrong way they can go past a certain value. If they do, the sides will go red and a sound will play. After the sound I want my webcam to stop capturing and start playing a video with an animation showing how to lift the box the correct way. My problem here is that I can not get my video to work. Here is my code:
If you move a blue object near the sides, the sides go red and you hear a sound. For 1 second you see a video pop up and then it stops. How can I get this to play?
- Sasmaz
For my school project I need to create an exhibition. My exhibition is about spinal hernia. I want my visitors to see themself lifting up a box(a light one) in the correct way. If they lift it the wrong way they can go past a certain value. If they do, the sides will go red and a sound will play. After the sound I want my webcam to stop capturing and start playing a video with an animation showing how to lift the box the correct way. My problem here is that I can not get my video to work. Here is my code:
- import processing.video.*;
- import ddf.minim.*;
- Capture cam;
- Movie myMovie;
- Minim minim;
- AudioPlayer player;
- int cx = 160, cy = 400, radius = 200;
- color target = color(0, 0, 200);
- PImage spiegel;
- void setup() {
- size(1024, 680, P2D);
- cam = new Capture(this, width, height, 24);
- spiegel = createImage(width, height, RGB);
- minim = new Minim(this);
- player = minim.loadFile("Wrenched.wav", 512);
- myMovie = new Movie (this, "test.mov");
- }
- void draw() {
- if (cam.available()) {
- cam.read();
- image(cam, 0, 0);
- cam.loadPixels();
- for (int i = 0; i <cam.pixels.length; i++) {
- spiegel.pixels[i] = cam.pixels[cam.width + (cam.width*(i/cam.width)) - 1 - i%cam.width];
- }
- spiegel.updatePixels();
- image(spiegel, 0, 0);
- int drempel = 120;
- int loc;
- int teller = 0;
- int pixelDrempel = 10;
- noFill();
- // 5 regels van @Alwin de Rooij
- for(int x=0; x<cam.width; x++) {
- for(int y=0; y<cam.height; y++) {
- loc = x + (y*cam.width);
- if(dist(red(cam.pixels[loc]), green(cam.pixels[loc]), blue(cam.pixels[loc]), red(target), green(target), blue(target)) < drempel) {
- if(dist(cx, cy, x, y) < radius/2) {
- teller++;
- }
- }
- }
- }
- rect(0, 0, 256, 680);
- rect(768, 0, 256, 680);
- myMovie.stop();
- if(teller > pixelDrempel){
- fill(255,0 ,0);
- rect(0, 0, 256, 680);
- player.play();
- myMovie.play();
- image(myMovie, 0, 0);
- }
- if(teller > pixelDrempel){
- fill(255,0 ,0);
- rect(768, 0, 256, 680);
- player.play();
- }
- if(player.position() == 2630){
- player.rewind();
- }
- //player.position();
- //println(player.position());
- }
- }
- void movieEvent(Movie m){
- m.read();
- }
If you move a blue object near the sides, the sides go red and you hear a sound. For 1 second you see a video pop up and then it stops. How can I get this to play?
- Sasmaz