* @author Florian Frankenberger
*/
-
class EyeDetector {
-
private int width;
-
+
private int height;
-
+
private int[] pixelBuffer;
-
+
double percent;
public EyeDetector(Image image, Rectangle2D faceRect) {
}
-
public Point detectEye() {
- Point eyePosition = null;
- float brightness = 255f;
- for ( int y = 0; y < height; ++y) {
- for ( int x = 0; x < width; ++x) {
- final int position = y * width + x;
- final int[] color =
- new int[] { (pixelBuffer[position] & 0xFF0000) >> 16,
- (pixelBuffer[position] & 0x00FF00) >> 8, pixelBuffer[position] & 0x0000FF };
+ Point eyePosition = null;
+ float brightness = 255f;
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ int position = y * width + x;
+ int[] color = new int[] { (pixelBuffer[position] & 0xFF0000) >> 16, (pixelBuffer[position] & 0x00FF00) >> 8, pixelBuffer[position] & 0x0000FF };
// System.out.println("("+x+","+y+")="+color[0]+" "+color[1]+" "+color[2]);
- final float acBrightness = getBrightness(color);
+ float acBrightness = getBrightness(color);
if (acBrightness < brightness) {
eyePosition = new Point(x + (int) percent, y + (int) percent);
return eyePosition;
}
-
- private static float getBrightness( int[] color) {
- int min = Math.min(Math.min(color[0], color[1]), color[2]);
- int max = Math.max(Math.max(color[0], color[1]), color[2]);
+ private static float getBrightness(int[] color) {
+ int min = Math.min(Math.min(color[0], color[1]), color[2]);
+ int max = Math.max(Math.max(color[0], color[1]), color[2]);
return 0.5f * (max + min);
}