Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. import hypermedia.video.*;
  2. import processing.opengl.*;
  3. import codeanticode.gsvideo.*;
  4. import codeanticode.glgraphics.*;
  5.  
  6. GSCapture cam;
  7. OpenCV opencv;
  8. GLTexture tex1;
  9.  
  10. //Cell[] = cells;
  11.  
  12. void setup(){
  13.  
  14.  
  15. size(640, 480, GLConstants.GLGRAPHICS);
  16. colorMode(RGB, 255, 255, 255, 100);
  17. smooth();
  18. frameRate(30);
  19.  
  20. opencv = new OpenCV( this );
  21. opencv.capture( width, height );
  22. opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
  23.  
  24. // cells = new Cell[16];
  25. // for(int c=0;c<faces.length;c++) {
  26. //
  27. // cells = new Cell[c];
  28. // }
  29. }
  30.  
  31.  
  32. public void stop() {
  33. opencv.stop();
  34. super.stop();
  35. }
  36.  
  37.  
  38. void draw(){
  39.  
  40. opencv.read();
  41. Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
  42. image( opencv.image(), 0, 0 );
  43.  
  44.  
  45.  
  46. // capture area //
  47. for( int i=0; i< faces.length ; i++ ) {
  48. noFill();
  49. stroke(255,255,0);
  50. rect( faces[i].x, faces[i].y , faces[i].width, faces[i].height );
  51. }
  52.  
  53.  
  54. // cell draw //
  55.  
  56. for( int j=0; j< faces.length ; j++ ){
  57.  
  58. float cellSizeX = faces[j].width / 4;
  59. float cellSizeY = faces[j].height / 4;
  60.  
  61. // float cellX = i*cellSizeX;
  62. // float cellY = j*cellSizeY;
  63.  
  64.  
  65. float spacingX = faces[j].width / 4;
  66. float spacingY = faces[j].height / 4;
  67.  
  68. translate(faces[j].x , faces[j].y);
  69.  
  70. for ( float k=0; k<4; k++)
  71. for ( float l=0; l<4; l++){
  72.  
  73. // float(frameCount) = randomizor , assign different frameRate animation on different objects
  74. // image(cells[c], faces[j].x*k , faces[j].y*l , cellSizeX , cellSizeY);
  75.  
  76. stroke(0);
  77. fill(255,0,0);
  78. // image = cells[].filename;
  79. rect(k*spacingX,l*spacingY,cellSizeX,cellSizeY);
  80.  
  81. }
  82. }
  83.  
  84.  
  85. }
  86.  
  87.  
  88. //****//
  89.  
  90.  
  91. PImage imgs[];
  92.  
  93.  
  94. String[] filenames;
  95. String[] mapping[];
  96.  
  97. for(int c = 0; c < 10; c++) {
  98.  
  99. filenames[c] = "cell" + c + ".png";
  100.  
  101. int img[c] = round(random(0,mapping[c].length));
  102.  
  103. }
  104.  
  105.  
  106. class Cell{
  107.  
  108. float xPos;
  109. float yPos;
  110.  
  111. filenames = new String[];
  112.  
  113.  
  114.  
  115. }
Add Comment
Please, Sign In to add comment