java - How to detect multiple faces using opencv in order to generate an output of flickering LED lights -


i new @ using processing , opencv, please bear me. have posted question on both stackoverflow , on processing forum reach wider audience , find solution -- apologies if looks if carelessly cross posting, not intentions.

i have been working on light installation using arduino , processing. capturing people using face detection webcam , opencv, , translating light installation working off 16x32 led matrix panel. light installation response of amount of spectators viewing lights , being recorded @ same time - idea more people being recorded generate greater display of flickering lights, , when no 1 viewing/being recorded, lights not flicker.

i have managed opencv detect faces , output arduino display on lights, can lights flash more intensely when people not being detected, rather when being detected. therefore, lights working in reverse, , flicker more when no-one being detected, , less when there people being detected.

i have attached both processing , arduino code reference, although not think arduino code needs changed @ all.

( have highlighted area in processing code believe part causing issue)

i appreciate knows way of changing face detection triggers more lights

thanks

processing code

 import gab.opencv.*;  import java.awt.*;  import processing.video.*;  import processing.serial.*;  import java.awt.color;   capture video;  opencv opencv;   serial myport;  // create object serial class  int inbyte = -1;    void setup()   {    size(640, 480);    video = new capture(this, 640/2, 480/2);    opencv = new opencv(this, 640/2, 480/2);    opencv.loadcascade(opencv.cascade_frontalface);    video.start();     println(serial.list());    //colormode(hsb, 100,100,100);    string portname = serial.list()[5];    myport = new serial(this, serial.list()[5], 9600);   }   void draw() {     scale(2);    opencv.loadimage(video);     image(video, 0, 0 );     nofill();    stroke(0, 255, 0);    strokeweight(3);    rectangle[] faces = opencv.detect();    println(faces.length);   //  cool stuff here:       int x = int(random(32));      int y = int(random(16));      int h = int(222);      int s = int(5);      int l = int(random(3));        int r =  int(random(255));      int g =  int(random(255));      int b =  int(random(255));        int f = 0;      string toard = x + ":" + y + ":" + r + ":" + g + ":" + b + ":" + f +".";        myport.write(toard);         **for (int = 0; < faces.length; i++) {         rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);        toard = x + ":" + y + ":" + 0 + ":" + 0 + ":" + 0 + ".";         myport.write(toard);         if (faces.length == 0){         delay(faces[0].x);          }     }**        // listen serial data arduino      // handy debugging         while (myport.available () > 0) {           // send string arduino on serial port          inbyte = myport.read();       }    }    void captureevent(capture c) {    c.read();  } 

arduino code

 const char eopmarker = '.';  char serialbuf[32];   #include <adafruit_gfx.h>  #include <rgbmatrixpanel.h> // hardware-specific library  #define max_string_len 20  #include <string.h>   #define clk 8  // must on portb! (use pin 11 on mega)  #define lat a3  #define oe  9  #define   a0  #define b   a1  #define c   a2  rgbmatrixpanel matrix(a, b, c, clk, lat, oe, false);   uint8_t r=7, g=7, b=7;   void setup() {      serial.begin(9600);    matrix.begin();    pinmode(13, output);    digitalwrite(13, low);  }   void loop() {        if (serial.available() > 0) {        static int bufpos = 0;         char inchar = serial.read();          if (inchar != eopmarker) {           serialbuf[bufpos] = inchar;           bufpos++;          }         else {            serialbuf[bufpos] = 0;           bufpos = 0; ![]()         }     // grab x y hsb values , whatever thing nice <span class="emoticon emoticon1"><span>:)</span></span>                  // send processing debugging             int x = atoi(substr(serialbuf, ":", 1));           int y = atoi(substr(serialbuf, ":", 2));           int r = atoi(substr(serialbuf, ":", 3));           int g = atoi(substr(serialbuf, ":", 4));           int b = atoi(substr(serialbuf, ":", 5));           int f = atoi(substr(serialbuf, ":", 6));             float vr = map(r, 0,255, 0,7);           float vg = map(g, 0,255, 0,7);           float vb = map(b, 0,255, 0,7);             serial.write(x);        matrix.drawpixel(x, y, matrix.color333(vr, vg, vb));        }   }    // function allows grab item string index   char* substr (char* input_string, char *separator, int segment_number) {    char *act, *sub, *ptr;    static char copy[max_string_len];    int i;    strcpy(copy, input_string);    (i = 1, act = copy; <= segment_number; i++, act = null) {      sub = strtok_r(act, separator, &ptr);      if (sub == null) break;    }    return sub;   } 


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -