HeadTracking Negative Space

Hey Guys,

So I am prototyping on processing.
The effect I would want to achieve is same as the https://www.youtube.com/watch?v=Jd3-eiid-Uw.
Another reference

I am using openCV for head tracking, it works.
Now I am moving the camera position according to the head tracking position, the camera would not always be in front of my object. Like the pic, there is an angle if the camera is not in front of the camera.

What it should be is, if we look at the object through the camera from an angle, we should stay in front of the object, just cant not see all the sides.

So I realised, it is not just the position or rotation of the camera, it is relative space. I could link both camera position and camera centre to face tracking position to keep the camera stay in front of the object, but in that case the rendered object also moves.
Here I have a simple draft I used Mouse Position to replace Head Tracking to simulate the problem.

void setup() {
size(1640, 1640, P3D);


}

void draw() {
clear();
background(255);

float x=map(mouseX,0,640,-320,320);
float y=map(mouseY,0,640,-320,320);

pushMatrix();
translate(width/2,height/2,0);
noFill();
strokeWeight(5);
box(323,323,323);
popMatrix();

//move both camera position and camera centre
camera(width/2+x, height/2.0+y, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0+x, height/2.0+y, 0, 0, 1, 0);
//move camera position only
// camera(width/2+x, height/2.0+y, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);


println(mouseX);

}

And also the original code for the head tracking one if needed

import gab.opencv.*;
import processing.video.*;
import java.awt.*;



int rot1=0;
int rot2=0;
int rot3=0;
Capture video;
OpenCV opencv;
float smoothedrot1=0;
float smoothedrot2=0;
float smoothedrot3=0;


void setup() 
{
  fullScreen(P3D);
  frameRate(60);

  video = new Capture(this, 320, 240);
  opencv = new OpenCV(this, 320, 240);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  


  video.start();
  
}

void draw()
{
  clear();
  //scale(0.5);
  //translate(0,0,750);
  opencv.loadImage(video);
  image(video, 0, 0,0,0);
  noFill();
  Rectangle[] faces = opencv.detect();
  println(faces.length);
  for (int i = 0; i < faces.length; i++) 
  {
    rot1=(faces[i].x+faces[i].width/2)-opencv.width/2;
    rot2=(faces[i].y+faces[i].height/2)-opencv.height/2;
    rot3=faces[i].width+faces[i].height;
    println(rot1 + "," + rot2);
   }
  smoothedrot1=lerp(smoothedrot1,rot1,0.4);
  smoothedrot2=lerp(smoothedrot2,rot2,0.4);
  smoothedrot3=lerp(smoothedrot3,rot3,0.1);

  beginShape();
  //float i=0;
  //float y=map(i,-800,900,0,mouseX);
  camera(smoothedrot1*2, smoothedrot2*1, -200-740+smoothedrot3, 0.0, 0.0, 0.0, 0.0, 0.02, 0.0); 
 //camera(-400+y, mouseY, -740+smoothedrot3, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); 

  rotateZ(PI);
  stroke(255,255,255);
  strokeWeight(15);
  fill(54,54,255);
  box(1440,900,2500);


  pointLight(255, 255, 255, -300, -300, -600);
  pointLight(255, 255, 255, 200, 200, -600);
  noStroke();
  fill(255,0,0);
  
  box(40,30,800);
  
  
      
 
 
  
}

Apologies, for some reason (new user account post w links?) it looks like your discussion was unlisted by the system. I have listed it.

Hi,
One student team has delivered this code to my as their project for a course.

I wonder if you could verify that this code is yours and who you are.

You can find me at daniel.gayo@gmail.com.

Thanks, Dani

@danielgayo – were you able to contact @Bianyx (or whoever you needed to) for this?

I received no reply.

However I questioned the students and they admitted the plagiarism.

Thank you.

2 Likes