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

motion detection (or sound detection) question

$
0
0
Hi,

I'm new in Processing.
In this project I would like to make the myMovie2 ("direita.mov") appear only when there is movement (or sound).

I only put if (mousePressed) {
to check if the code was correct.

What should I do?
I also can't find why my movie is really slow...

Thank you very much for any help!






  1. import processing.video.*;
  2. Capture cam;
  3. Movie myMovie, myMovie2;
  4. void setup() {
  5.   size(1440, 576);
  6.  
  7.   myMovie = new Movie(this, "normal.mov");
  8.   myMovie2 = new Movie(this, "direita.mov");
  9.   myMovie.speed(100.0);
  10.   myMovie.loop();
  11.   myMovie2.loop();
  12.   String[] cameras = Capture.list();
  13.  
  14.   if (cameras.length == 0) {
  15.     println("There are no cameras available for capture.");
  16.     exit();
  17.   } else {
  18.     println("Available cameras:");
  19.     for (int i = 0; i < cameras.length; i++) {
  20.       println(cameras[i]);
  21.     }
  22.    
  23.     cam = new Capture(this, cameras[0]);
  24.     cam.start(); 
  25.   }     
  26. }
  27. void draw() {
  28.   if (myMovie.available()) {
  29.     myMovie.read();
  30.     image(myMovie, 0, 0, 720, 576);
  31.   }
  32.  
  33.   if (mousePressed) {  // what should I put here?
  34.     myMovie2.read();
  35.     image(myMovie2, 0, 0, 720, 576);
  36.   }
  37.   if (cam.available() == true)
  38.     cam.read();
  39.    
  40.   image(cam, width/2, 0, 720, 576);
  41. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles