Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Can't play video with my webcam on.

$
0
0
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:

  1. import processing.video.*;
  2. import ddf.minim.*;

  3. Capture cam;
  4. Movie myMovie;
  5. Minim minim;
  6. AudioPlayer player;

  7. int cx = 160, cy = 400, radius = 200;
  8. color target = color(0, 0, 200);

  9. PImage spiegel;

  10. void setup() {

  11.   size(1024, 680, P2D);
  12.   cam = new Capture(this, width, height, 24);
  13.   spiegel = createImage(width, height, RGB);
  14.  
  15.   minim = new Minim(this);
  16.   player = minim.loadFile("Wrenched.wav", 512);
  17.  
  18.   myMovie = new Movie (this, "test.mov"); 

  19. }

  20. void draw() {
  21.   if (cam.available()) {
  22.     cam.read();
  23.     image(cam, 0, 0);
  24.     cam.loadPixels();
  25.     for (int i = 0; i <cam.pixels.length; i++) {
  26.       spiegel.pixels[i] = cam.pixels[cam.width + (cam.width*(i/cam.width)) - 1 - i%cam.width];
  27.     }

  28.     spiegel.updatePixels();
  29.    
  30.     image(spiegel, 0, 0);
  31.     int drempel = 120;
  32.     int loc;
  33.     int teller = 0;
  34.     int pixelDrempel = 10;
  35.     noFill();

  36. // 5 regels van @Alwin de Rooij
  37.     for(int x=0; x<cam.width; x++) {
  38.       for(int y=0; y<cam.height; y++) {
  39.         loc = x + (y*cam.width);
  40.         if(dist(red(cam.pixels[loc]), green(cam.pixels[loc]), blue(cam.pixels[loc]), red(target), green(target), blue(target)) < drempel) {
  41.           if(dist(cx, cy, x, y) < radius/2) {
  42.             teller++;
  43.           }
  44.         }
  45.       }
  46.     }
  47.    
  48.     rect(0, 0, 256, 680);
  49.     rect(768, 0, 256, 680);
  50.    
  51.     myMovie.stop();
  52.     if(teller > pixelDrempel){
  53.       fill(255,0 ,0);
  54.       rect(0, 0, 256, 680);
  55.      
  56.       player.play();
  57.      
  58.       myMovie.play();   
  59.       image(myMovie, 0, 0);
  60.     
  61.     }
  62.    
  63.     if(teller > pixelDrempel){
  64.       fill(255,0 ,0);
  65.       rect(768, 0, 256, 680);
  66.       player.play();
  67.     }
  68.    
  69.     if(player.position() == 2630){
  70.       player.rewind();
  71.     }
  72.     //player.position();
  73.     //println(player.position());
  74.        
  75.   }
  76. }
  77. void movieEvent(Movie m){
  78.   m.read();
  79. }



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

Viewing all articles
Browse latest Browse all 1768

Trending Articles