Hi...
I want to do like this
link.
Here is code for facedetection
- import hypermedia.video.*;
- import java.awt.Rectangle;
- OpenCV opencv;
- void setup() {
- size( 640, 480 );
- opencv = new OpenCV(this);
- opencv.capture( width, height );
- opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load the FRONTALFACE description file
- }
- void draw() {
- opencv.read();
- image( opencv.image(), 0, 0 );
- // detect anything ressembling a FRONTALFACE
- Rectangle[] faces = opencv.detect();
- // draw detected face area(s)
- noFill();
- stroke(255,0,0);
- for( int i=0; i<faces.length; i++ ) {
- rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
- }
- }
- // simulate loadStrings
- String[] TestCSV = {
- "Hello,you,!,Funny",
- "11,18,9,2,12",
- "36,28,90,5,24",
- "What,good,,,"
- };
- // your target
- String[][]myStringArray;
- int faceNumber = 0;
- boolean mouseHold=false;
- void setup() {
- size(1000, 1000);
- // String[][] TestCSV = loadStrings ( ..................
- myStringArray = new String[0][0];
- String[] a1;
- for (int i=0;i<TestCSV.length;i++) {
- a1 = split(TestCSV [i], ",");
- myStringArray = (String[][]) append (myStringArray, a1);
- }
- faceNumber=0;
- println(myStringArray.length);
- println(myStringArray[0].length);
- println("-------------------");
- for (int i=0;i<myStringArray.length;i++) {
- for (int j=0;j<myStringArray[i].length;j++) {
- print (myStringArray[i][j] + " " );
- }
- println();
- }
- } // func
- void draw() {
- background(0);
- fill(255);
- text ("Drag the mouse, please", 111, 100);
- if (mouseHold) {
- switch (faceNumber) {
- case 0:
- fill ( faceNumber * 20+140, faceNumber*1, 110);
- break;
- case 1:
- fill(255, 1, 2);
- break;
- default:
- fill(0, 0, 255);
- break;
- } // switch
- for (int i=0;i<myStringArray.length;i++) {
- text ( myStringArray [ faceNumber ] [ i ], mouseX-9, mouseY-i*22-9) ;
- }
- } // if
- } // func
- void mousePressed() {
- //
- mouseHold=true;
- }
- void mouseReleased() {
- mouseHold=false;
- faceNumber++;
- if (faceNumber>=myStringArray.length)
- faceNumber=0;
- }
thanking you in anticipation
1