Exemplo n.º 1
0
  @Override
  public void onFaceDetection(Camera.Face[] faces, Camera camera) {
    RectF rectf = new RectF();

    for (Camera.Face face : faces) {
      int centerX = face.rect.centerX();
      int centerY = face.rect.centerY();

      android.graphics.Matrix matrix = new android.graphics.Matrix();
      // Width needs to be divided by 2 because the overlay is for both eyes:
      prepareMatrix(matrix, false, mOverlayView.getWidth() / 2, mOverlayView.getHeight());
      rectf.set(face.rect);
      matrix.mapRect(rectf);

      mOverlayView.show3DRect((int) rectf.centerX(), (int) rectf.centerY());
      mOverlayView.show3DToast("Found face! x = " + rectf.centerX() + ", y = " + rectf.centerY());
    }
  }
Exemplo n.º 2
0
  /**
   * Sets the view to our CardboardView and initializes the transformation matrices we will use to
   * render our scene.
   *
   * @param savedInstanceState
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.common_ui);
    cardboardView = (CardboardView) findViewById(R.id.cardboard_view);
    cardboardView.setRenderer(this);
    setCardboardView(cardboardView);

    mCamera = new float[16];
    mView = new float[16];

    mOverlayView = (CardboardOverlayView) findViewById(R.id.overlay);
    mOverlayView.show3DToast("Not every day is Purim.");
  }
  /**
   * Sets the view to our CardboardView and initializes the transformation matrices we will use to
   * render our scene.
   *
   * @param savedInstanceState
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.common_ui);
    cardboardView = (CardboardView) findViewById(R.id.cardboard_view);
    cardboardView.setRenderer(this);
    setCardboardView(cardboardView);

    //        mModelCube = new float[16];
    mCamera = new float[16];
    mView = new float[16];
    //        mModelViewProjection = new float[16];
    //        mModelView = new float[16];
    //        mModelFloor = new float[16];
    //        mHeadView = new float[16];
    //        mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    //
    //
    mOverlayView = (CardboardOverlayView) findViewById(R.id.overlay);
    mOverlayView.show3DToast("Pull the magnet when you find an object.");
  }