release of proscene 1.1
- Generic support for Human Interface Devices.
- Off-screen rendering has been greatly improved.
- Better screen drawing (i.e., drawing of 2d primitives on top of a 3d scene).
- New examples: CameraCrane, SpaceNavigator, and Woobik.
opencv.read(); // grab images from THE CAMERA
opencv.convert( GRAY );// convert image to gray scale
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 60, 40 ); // detect face
lights();
noFill();
if (faces.length > 0) {
for( int i=0; i<faces.length; i++ ) {
float invDist = float(faces[i].height * 10);
if(invDist >= maxZ)
{
maxZ = invDist;
}
z = maxZ-invDist;
float distance = z;
faceWidth = faces[i].width;
faceX = faces[i].x;
faceY = faces[i].y;
faceZ = distance;
resetArr(xArr, faceX);/// smoothing
resetArr(yArr, faceY);
resetArr(zArr, faceZ);
avgX = average(xArr);
avgY = average(yArr);
avgZ = average(zArr);
presentX += (avgX - presentX) * 0.5;
presentY += (avgY - presentY) * 0.5;
presentZ += (avgZ - presentZ) * 0.5;
camCenterX = (avgX);
camY = round(((-height/2+presentY*4)*HALF_PI)+200);
camCenterY = round(avgY);
camZ = presentZ;
camCenterZ = -avgZ; //was previously -z
camCenterX= camCenterXb;// here are the camera resets to new points from no face detect
camCenterX=camCenterXb;
camCenterY= camCenterYb;
camCenterY=camCenterYb;
camCenterZ= camCenterZb;
camCenterZ=camCenterZb;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// camera circular paths for second if condition
camX = round(-(-width/2+presentX*4)*HALF_PI);
camY = round(((-height/2+presentY*4)*HALF_PI)+200);
//z = faces[i].height*10;
camZ = presentZ; // was previously distance; also avgZ
velocityX = xArr[0] - xArr[7] ; // working out the velocity.
velocityX = velocityX/15*10;
velocityY = yArr[0] + yArr[7] ;
velocityY = velocityY/15;
velocityZ = zArr[0] - zArr[7] ;
velocityZ = velocityZ/15*10;
resetArr(cxArr, camCenterX);/// smoothing
resetArr(cyArr, camCenterY);
resetArr(czArr, camCenterZ);
cavgX = average(cxArr);
cavgY = average(cyArr);
cavgZ = average(czArr);
cpresentX += (cavgX - cpresentX) * 1.1;
cpresentY += (cavgY - cpresentY) * 1.1;
cpresentZ += (cavgZ - cpresentZ) * .1;
////////////////////////////////////////////////////////////////////////////////
/*THIS IS THE SECTION WHERE IF THE TRACKING GOES BEYOND A CERTAIN POSITION
ON THE X AXIS, THEN FOR THE CAMERA TO ORBIT AROUND THE CENTRE POINT UNTIL THE HEAD IS
TRACKED AGAIN, WHERE BY THE HEAD TRACKING CONTINUES FROM THAT POINT.*//
//////////////////////////////////////////////////////////////////////////
if (faces.length == 0) { // for more than a few frames
if ( camX > 650){
camX = orbitRadius * acos(radians(camAlpha))*acos(radians(camBeta));
camAlpha= camAlpha + velocityX;
if (camX <= -100) {
camX = camX +velocityX ;
camCenterXb= camCenterX + velocityX;
camCenterX=camCenterXb;
}
}
camera(camX, camY, camZ, // eyeX, eyeY, eyeZ
camCenterX, camCenterY, camCenterZ, // centerX, centerY, centerZ
0.0, 1.0, 0.0); // upX, upY, upZ
directionalLight(255,255,255,-1,0.5,0);