public svm_node[] extractEyesTemplate(int x0,int y0,int x1,int y1) {
		int xDistance,yDistance;
		int startX,startY;
		int currentX,currentY;
		int Ox,Oy;
	    double xRes,yRes;
	    double offsetY;
	    double scaleFactor;
	    
	    svm_node node;
	    svm_node template[] = new svm_node[735]; /* template size is 21*35 samples */
	    
	    /* distance between eyes on x and y axis */ 
	    xDistance = x1 - x0;
	    yDistance = y1 - y0;
	    
	    /* distance between the eyes is 23 pixels from experiences 
	     * calculate the scale factor for each axis
	     * */
	    xRes = (double)xDistance / 23d; 
	    yRes = (double)yDistance / 23d;
	    
	    /* scale factor */
	    scaleFactor = Math.sqrt(Math.pow(xDistance,2)+Math.pow(yDistance,2))/23d;
	    
	    /* 6 from (35 - 23)/2 and 8 because the eyes are on the 8 row from experiments*/
	    Ox = x0 - (int)(6*xRes) + (int)(8*yRes);
	    offsetY = (yDistance != 0 ? (8*yRes*xDistance) / yDistance : 8*scaleFactor);
	    Oy = y0 -(int)offsetY;
	    
        /* rotate the template to a horizontal position */
	    startX = Ox;
	    startY = Oy; 
	    for (int y = 0; y < 21; y++) {
	    	currentX = startX;
	    	currentY = startY;
	    	for (int x = 0; x < 35; x++) {
	    		node = new svm_node();
	    		node.index = y * 35 + x + 1;
	    		if ( (currentX >= 0) && (currentX < frameWidth) && 
	    			 (currentY < frameHeight) && (currentY >= 0) ) {
	    			/* convert data in the svm format */
	    			node.value = grayPixels[currentY * frameWidth + currentX] / 255d;
	    		} else {
	    			if (y == 0) {
	    				node.value = 128d / 255d;
	    			} else {
	    				node.value = template[ (y - 1) * 35 + x].value;
	    			}
	    		}
	    		template[y * 35 + x] = node;
	    		currentX = startX+(int)((x+1)*xRes);
	    		currentY = startY+(int)((x+1)*yRes);
	    	}
	    	startX = Ox - (int)((y+1)*yRes);
	    	startY = Oy + (int)((y+1)*xRes);
	    }
	    
	    return template;
	  }