Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hypermedia.video.*;
- import processing.opengl.*;
- import codeanticode.gsvideo.*;
- import codeanticode.glgraphics.*;
- GSCapture cam;
- OpenCV opencv;
- GLTexture tex1;
- //Cell[] = cells;
- void setup(){
- size(640, 480, GLConstants.GLGRAPHICS);
- colorMode(RGB, 255, 255, 255, 100);
- smooth();
- frameRate(30);
- opencv = new OpenCV( this );
- opencv.capture( width, height );
- opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
- // cells = new Cell[16];
- // for(int c=0;c<faces.length;c++) {
- //
- // cells = new Cell[c];
- // }
- }
- public void stop() {
- opencv.stop();
- super.stop();
- }
- void draw(){
- opencv.read();
- Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
- image( opencv.image(), 0, 0 );
- // capture area //
- for( int i=0; i< faces.length ; i++ ) {
- noFill();
- stroke(255,255,0);
- rect( faces[i].x, faces[i].y , faces[i].width, faces[i].height );
- }
- // cell draw //
- for( int j=0; j< faces.length ; j++ ){
- float cellSizeX = faces[j].width / 4;
- float cellSizeY = faces[j].height / 4;
- // float cellX = i*cellSizeX;
- // float cellY = j*cellSizeY;
- float spacingX = faces[j].width / 4;
- float spacingY = faces[j].height / 4;
- translate(faces[j].x , faces[j].y);
- for ( float k=0; k<4; k++)
- for ( float l=0; l<4; l++){
- // float(frameCount) = randomizor , assign different frameRate animation on different objects
- // image(cells[c], faces[j].x*k , faces[j].y*l , cellSizeX , cellSizeY);
- stroke(0);
- fill(255,0,0);
- // image = cells[].filename;
- rect(k*spacingX,l*spacingY,cellSizeX,cellSizeY);
- }
- }
- }
- //****//
- PImage imgs[];
- String[] filenames;
- String[] mapping[];
- for(int c = 0; c < 10; c++) {
- filenames[c] = "cell" + c + ".png";
- int img[c] = round(random(0,mapping[c].length));
- }
- class Cell{
- float xPos;
- float yPos;
- filenames = new String[];
- }
Add Comment
Please, Sign In to add comment