import java.io.Serializable; import processing.core.PVector; /** * This class will handle storing and calculating projected screen dimesions. * Serializable so we can just write the current calibration to file mostly. */ public class Calibration implements Serializable { public PVector screenDimensions; public PVector offset; public PVector topLeft; public PVector bottomRight; public Calibration() { screenDimensions = new PVector(); offset = new PVector(); topLeft = new PVector(); bottomRight = new PVector(); } public void recalculate() { screenDimensions.set( bottomRight.x - topLeft.x, topLeft.y - bottomRight.y); // if the two calibration points are symmetric, the offset should be 0 PVector kinectScreenOrigin = PVector.div(PVector.add(bottomRight, topLeft), 2f); offset.set( kinectScreenOrigin.x - topLeft.x, kinectScreenOrigin.y - bottomRight.y, kinectScreenOrigin.z); /* System.out.println("Screen Calibration: " + screenWidth + ", " + screenHeight + " " + screenDistance); System.out.println("Bottom Right: " + bottomRight.x + ", " + bottomRight.y); System.out.println("Upper Left: " + upperLeft.x + ", " + upperLeft.y); System.out.println("Offset: " + offset.x + ", " + offset.y); */ } }