turn sketch into 3D
in
Programming Questions
•
2 years ago
I am currently working on a code that has two images, one on top of the other. It works with openCV and when a face is detected, the "square" in which the face is in, deletes the pixels of the image on the top and allows the image on the background to show.
here is the code:
import hypermedia.video.*;
import java.awt.Rectangle;
PImage banner1;
PImage banner2;
PImage temp;
String state = "";
OpenCV opencv;
int contrast_value = 0;
int brightness_value = 0;
void setup(){
size(640,480);
opencv = new OpenCV( this );
opencv.capture( width, height );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT );
noStroke();
frameRate(30);
banner1 = loadImage("17p.jpg");
banner1.loadPixels();
banner2 = loadImage("17.jpg");
banner2.loadPixels();
background(banner2);
}
public void stop() {
opencv.stop();
super.stop();
}
void draw(){
opencv.read();
opencv.convert( GRAY );
opencv.contrast( contrast_value );
opencv.brightness( brightness_value );
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
temp = banner1.get(faces[i].x,faces[i].y,100,100);
image(temp,faces[i].x,faces[i].y);
}
}
void mouseDragged(){
if (mouseX >0 && mouseX < width && mouseY >0 && mouseY < height-30){
temp = banner1.get(mouseX,mouseY,100,100);
image(temp,mouseX,mouseY);
}
}
Now what I am trying to do is make this sketch a 3d sketch.
I have tried using some of the code used in the 3D processing examples but it doesn't have the results that i was expecting.
any ideas?
2