visageSDK
DetectorRenderer.java
1 package com.visagetechnologies.facedetectdemo;
2 
3 import javax.microedition.khronos.egl.EGLConfig;
4 import javax.microedition.khronos.opengles.GL10;
5 import javax.microedition.khronos.opengles.GL11;
6 import javax.microedition.khronos.opengles.GL11Ext;
7 
8 import android.content.Context;
9 import android.graphics.Bitmap;
10 import android.graphics.Canvas;
11 import android.graphics.Point;
12 import android.graphics.drawable.Drawable;
13 import android.opengl.GLSurfaceView;
14 import android.opengl.GLUtils;
15 import android.view.Display;
16 import android.view.WindowManager;
17 
20 public class DetectorRenderer implements GLSurfaceView.Renderer
21 {
22  int _width;
23  int _height;
24  int[] textures = new int[3];
25  Context _context;
26  boolean _detect;
27 
32  DetectorRenderer(Context context, boolean detect)
33  {
34  _context = context;
35  _detect = detect;
36  }
37 
43  public void onDrawFrame(GL10 gl)
44  {
45  gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
46  gl.glEnable(GL10.GL_BLEND);
47 
48  gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
49  if (_detect)
50  {
51  displayResults(_width, _height);
52  }
53  else
54  displayIdentity(_width, _height);
55 
56  }
57 
61  public void onSurfaceChanged(GL10 gl, int width, int height)
62  {
63  _width = width;
64  _height = height;
65 
66  }
67 
68  public void onSurfaceCreated(GL10 gl, EGLConfig config)
69  {
70  WindowManager wm = (WindowManager) _context.getSystemService(Context.WINDOW_SERVICE);
71  Display display = wm.getDefaultDisplay();
72  Point size = new Point();
73  display.getSize(size);
74 
75  gl.glGenTextures(3, textures, 0);
76  }
77 
78 
84  public native void displayResults(int width, int height);
85 
91  public native void displayIdentity(int width, int height);
92 
97  static
98  {
99  System.loadLibrary("VisageVision");
100  System.loadLibrary("FaceDetectorWrapper");
101  }
102 }
void onSurfaceChanged(GL10 gl, int width, int height)
Implementation of surfaceChanged method provided by SurfaceHolder.Callback class. ...
native void displayIdentity(int width, int height)
Interface to native method used to draw recognition results.
native void displayResults(int width, int height)
Interface to native method used to draw detection results.
void onDrawFrame(GL10 gl)
Implementation of onDrawFrame method provided by GLSurfaceView.Renderer interface.
TrackerRenderer class provides implementation of rendering functions required for displaying detectio...