How to capture an image relying on condition (example 2 clicks within a time limit)

How do I do this? Instead of 2 clicks, I use a mindwave-headset to register when i blink, and i want my camera to capture when i blink 2 times within, lets say 2 seconds. We have a minimum limit on the blinkstrength (how "hard" you blink), and we want 2 concesutive blinks above the limit within the time limit to capture an image.

Thanks in advance

Comments

  • edited January 2015

    Hello,

    your question is vague and you don't show any code...

    do you have code for mouse already?

    I wrote a code that takes mouse input (and not blinking) but demonstrates the timing (you wrote 2 seconds)...

    only when the timing is correct, we see println "fast" otherwise your blinking / mouse clicking was too fast or to slow...

    Did you ask for that part or what is your issue exactly?

    In my code you need to replace my mousePressed with you blink sensor (with blinkstrength).

    I hope this helps.

    Chrisir ;-)

        boolean hitOnce = false; // Has mouse already been clicked once? 
        int time1;
    
        void setup() {
          size (600, 660);
          background(0);
        }
    
        void draw() {
          // runs on and on 
          background(0);
          if (!hitOnce) 
            text ("Please mouse", 40, 110);
        }
    
        void mousePressed() {
    
          if (hitOnce) {
            // second time (hitOnce is true here) - mouse already been clicked once
    
            if (time1+200>millis()) {    // measure the time since timer....
              println ("too fast");
            }
            else if (time1+2000>millis()) {   // measure the time since timer....
              println ("Fast. Good.");
              // action : camera
            }
            else { 
              println ("too slow");
            }
            //
            hitOnce = false; // reset
          }  // if
          else 
          {
            // 1st time the mouse has been clicked
            hitOnce = true; 
            time1 = millis();   // start timer 
            println ("1st");
          }
        }
        //
    
Sign In or Register to comment.