Program: 38119
Project: 38119
Buggy source:
@Override protected void onDraw(Canvas canvas){
  if (!mBlocked && (mFaces != null) && (mFaces.length > 0)&& mCameraBound != null) {
    int rw, rh;
    rw=mUncroppedWidth;
    rh=mUncroppedHeight;
    if (((rh > rw) && ((mDisplayOrientation == 0) || (mDisplayOrientation == 180))) || ((rw > rh) && ((mDisplayOrientation == 90) || (mDisplayOrientation == 270)))) {
      int temp=rw;
      rw=rh;
      rh=temp;
    }
    CameraUtil.prepareMatrix(mMatrix,mMirror,mDisplayOrientation,rw,rh);
    Matrix translateMatrix=new Matrix();
    translateMatrix.preTranslate(-mCameraBound.width() / 2f,-mCameraBound.height() / 2f);
    translateMatrix.postScale(2000f / mCameraBound.width(),2000f / mCameraBound.height());
    Matrix bsgcTranslateMatrix=new Matrix();
    bsgcTranslateMatrix.preTranslate(-mCameraBound.width() / 2f * mZoom,-mCameraBound.height() / 2f * mZoom);
    bsgcTranslateMatrix.postScale(2000f / mCameraBound.width(),2000f / mCameraBound.height());
    int dx=(getWidth() - rw) / 2;
    int dy=(getHeight() - rh) / 2;
    canvas.save();
    mMatrix.postRotate(mOrientation);
    canvas.rotate(-mOrientation);
    float rectWidth;
    float rectHeight;
    float diameter;
    int extendFaceSize=0;
    extendFaceSize=mExFaces == null ? 0 : mExFaces.length;
    for (int i=0; i < mFaces.length; i++) {
      if (mFaces[i].getScore() < 50)       continue;
      Rect faceBound=mFaces[i].getBounds();
      faceBound.offset(-mCameraBound.left,-mCameraBound.top);
      mRect.set(faceBound);
      translateMatrix.mapRect(mRect);
      mMatrix.mapRect(mRect);
      mPaint.setColor(mColor);
      mRect.offset(dx,dy);
      rectHeight=mRect.bottom - mRect.top;
      rectWidth=mRect.right - mRect.left;
      diameter=rectHeight > rectWidth ? rectWidth : rectHeight;
      canvas.drawCircle(mRect.centerX(),mRect.centerY(),diameter / 2,mPaint);
      if (i < extendFaceSize && mExFaces[i] != null) {
        ExtendedFace exFace=mExFaces[i];
        Face face=mFaces[i];
        float[] point=new float[4];
        int delta_x=faceBound.width() / 12;
        int delta_y=faceBound.height() / 12;
        delta_x=(int)(delta_x * mZoom);
        delta_y=(int)(delta_y * mZoom);
        Log.e(TAG,"String_Node_Str" + exFace.getLeyeBlink() + "String_Node_Str"+ exFace.getReyeBlink()+ "String_Node_Str");
        if (face.getLeftEyePosition() != null) {
          if ((mDisplayRotation == 0) || (mDisplayRotation == 180)) {
            point[0]=face.getLeftEyePosition().x;
            point[1]=face.getLeftEyePosition().y - delta_y / 2;
            point[2]=face.getLeftEyePosition().x;
            point[3]=face.getLeftEyePosition().y + delta_y / 2;
          }
 else {
            point[0]=face.getLeftEyePosition().x - delta_x / 2;
            point[1]=face.getLeftEyePosition().y;
            point[2]=face.getLeftEyePosition().x + delta_x / 2;
            point[3]=face.getLeftEyePosition().y;
          }
          bsgcTranslateMatrix.mapPoints(point);
          mMatrix.mapPoints(point);
          if (exFace.getLeyeBlink() >= blink_threshold) {
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (face.getRightEyePosition() != null) {
          if ((mDisplayRotation == 0) || (mDisplayRotation == 180)) {
            point[0]=face.getRightEyePosition().x;
            point[1]=face.getRightEyePosition().y - delta_y / 2;
            point[2]=face.getRightEyePosition().x;
            point[3]=face.getRightEyePosition().y + delta_y / 2;
          }
 else {
            point[0]=face.getRightEyePosition().x - delta_x / 2;
            point[1]=face.getRightEyePosition().y;
            point[2]=face.getRightEyePosition().x + delta_x / 2;
            point[3]=face.getRightEyePosition().y;
          }
          bsgcTranslateMatrix.mapPoints(point);
          mMatrix.mapPoints(point);
          if (exFace.getReyeBlink() >= blink_threshold) {
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (exFace.getLeftrightGaze() != 0 || exFace.getTopbottomGaze() != 0) {
          double length=Math.sqrt((face.getLeftEyePosition().x - face.getRightEyePosition().x) * (face.getLeftEyePosition().x - face.getRightEyePosition().x) + (face.getLeftEyePosition().y - face.getRightEyePosition().y) * (face.getLeftEyePosition().y - face.getRightEyePosition().y)) / 2.0;
          double nGazeYaw=-exFace.getLeftrightGaze();
          double nGazePitch=-exFace.getTopbottomGaze();
          float gazeRollX=(float)((-Math.sin(nGazeYaw / 180.0 * Math.PI) * Math.cos(-exFace.getRollDirection() / 180.0 * Math.PI) + Math.sin(nGazePitch / 180.0 * Math.PI) * Math.cos(nGazeYaw / 180.0 * Math.PI) * Math.sin(-exFace.getRollDirection() / 180.0 * Math.PI)) * (-length) + 0.5);
          float gazeRollY=(float)((Math.sin(-nGazeYaw / 180.0 * Math.PI) * Math.sin(-exFace.getRollDirection() / 180.0 * Math.PI) - Math.sin(nGazePitch / 180.0 * Math.PI) * Math.cos(nGazeYaw / 180.0 * Math.PI) * Math.cos(-exFace.getRollDirection() / 180.0 * Math.PI)) * (-length) + 0.5);
          if (exFace.getLeyeBlink() < blink_threshold) {
            if ((mDisplayRotation == 90) || (mDisplayRotation == 270)) {
              point[0]=face.getLeftEyePosition().x;
              point[1]=face.getLeftEyePosition().y;
              point[2]=face.getLeftEyePosition().x + gazeRollX;
              point[3]=face.getLeftEyePosition().y + gazeRollY;
            }
 else {
              point[0]=face.getLeftEyePosition().x;
              point[1]=face.getLeftEyePosition().y;
              point[2]=face.getLeftEyePosition().x + gazeRollY;
              point[3]=face.getLeftEyePosition().y + gazeRollX;
            }
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
          if (exFace.getReyeBlink() < blink_threshold) {
            if ((mDisplayRotation == 90) || (mDisplayRotation == 270)) {
              point[0]=face.getRightEyePosition().x;
              point[1]=face.getRightEyePosition().y;
              point[2]=face.getRightEyePosition().x + gazeRollX;
              point[3]=face.getRightEyePosition().y + gazeRollY;
            }
 else {
              point[0]=face.getRightEyePosition().x;
              point[1]=face.getRightEyePosition().y;
              point[2]=face.getRightEyePosition().x + gazeRollY;
              point[3]=face.getRightEyePosition().y + gazeRollX;
            }
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (face.getMouthPosition() != null) {
          Log.e(TAG,"String_Node_Str" + exFace.getSmileDegree() + "String_Node_Str"+ exFace.getSmileConfidence());
          if (exFace.getSmileDegree() < smile_threashold_no_smile) {
            point[0]=face.getMouthPosition().x + dx - delta_x;
            point[1]=face.getMouthPosition().y;
            point[2]=face.getMouthPosition().x + dx + delta_x;
            point[3]=face.getMouthPosition().y;
            Matrix faceMatrix=new Matrix();
            faceMatrix.preRotate(exFace.getRollDirection(),face.getMouthPosition().x,face.getMouthPosition().y);
            faceMatrix.mapPoints(point);
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
 else           if (exFace.getSmileDegree() < smile_threashold_small_smile) {
            int rotation_mouth=360 - mDisplayRotation;
            mRect.set(face.getMouthPosition().x - delta_x,face.getMouthPosition().y - delta_y,face.getMouthPosition().x + delta_x,face.getMouthPosition().y + delta_y);
            bsgcTranslateMatrix.mapRect(mRect);
            mMatrix.mapRect(mRect);
            mRect.offset(dx,dy);
            canvas.drawArc(mRect,rotation_mouth,180,true,mPaint);
          }
 else {
            mRect.set(face.getMouthPosition().x - delta_x,face.getMouthPosition().y - delta_y,face.getMouthPosition().x + delta_x,face.getMouthPosition().y + delta_y);
            bsgcTranslateMatrix.mapRect(mRect);
            mMatrix.mapRect(mRect);
            mRect.offset(dx,dy);
            canvas.drawOval(mRect,mPaint);
          }
        }
      }
    }
    canvas.restore();
  }
  super.onDraw(canvas);
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas canvas){
  if (!mBlocked && (mFaces != null) && (mFaces.length > 0)&& mCameraBound != null) {
    int rw, rh;
    rw=mUncroppedWidth;
    rh=mUncroppedHeight;
    if (((rh > rw) && ((mDisplayOrientation == 0) || (mDisplayOrientation == 180))) || ((rw > rh) && ((mDisplayOrientation == 90) || (mDisplayOrientation == 270)))) {
      int temp=rw;
      rw=rh;
      rh=temp;
    }
    CameraUtil.prepareMatrix(mMatrix,mMirror,mDisplayOrientation,rw,rh);
    Matrix translateMatrix=new Matrix();
    translateMatrix.preTranslate(-mCameraBound.width() / 2f,-mCameraBound.height() / 2f);
    translateMatrix.postScale(2000f / mCameraBound.width(),2000f / mCameraBound.height());
    Matrix bsgcTranslateMatrix=new Matrix();
    bsgcTranslateMatrix.preTranslate(-mCameraBound.width() / 2f * mZoom,-mCameraBound.height() / 2f * mZoom);
    bsgcTranslateMatrix.postScale(2000f / mCameraBound.width(),2000f / mCameraBound.height());
    int dx=(getWidth() - rw) / 2;
    int dy=(getHeight() - rh) / 2;
    canvas.save();
    mMatrix.postRotate(mOrientation);
    canvas.rotate(-mOrientation);
    float rectWidth;
    float rectHeight;
    float diameter;
    int extendFaceSize=0;
    extendFaceSize=mExFaces == null ? 0 : mExFaces.length;
    for (int i=0; i < mFaces.length; i++) {
      if (mFaces[i].getScore() < 50)       continue;
      Rect faceBound=mFaces[i].getBounds();
      faceBound.offset(-mCameraBound.left,-mCameraBound.top);
      mRect.set(faceBound);
      translateMatrix.mapRect(mRect);
      if (LOGV)       CameraUtil.dumpRect(mRect,"String_Node_Str");
      mMatrix.mapRect(mRect);
      if (LOGV)       CameraUtil.dumpRect(mRect,"String_Node_Str");
      mPaint.setColor(mColor);
      mRect.offset(dx,dy);
      rectHeight=mRect.bottom - mRect.top;
      rectWidth=mRect.right - mRect.left;
      diameter=rectHeight > rectWidth ? rectWidth : rectHeight;
      canvas.drawCircle(mRect.centerX(),mRect.centerY(),diameter / 2,mPaint);
      if (i < extendFaceSize && mExFaces[i] != null) {
        ExtendedFace exFace=mExFaces[i];
        Face face=mFaces[i];
        float[] point=new float[4];
        int delta_x=faceBound.width() / 12;
        int delta_y=faceBound.height() / 12;
        delta_x=(int)(delta_x * mZoom);
        delta_y=(int)(delta_y * mZoom);
        Log.e(TAG,"String_Node_Str" + exFace.getLeyeBlink() + "String_Node_Str"+ exFace.getReyeBlink()+ "String_Node_Str");
        if (face.getLeftEyePosition() != null) {
          if ((mDisplayRotation == 0) || (mDisplayRotation == 180)) {
            point[0]=face.getLeftEyePosition().x;
            point[1]=face.getLeftEyePosition().y - delta_y / 2;
            point[2]=face.getLeftEyePosition().x;
            point[3]=face.getLeftEyePosition().y + delta_y / 2;
          }
 else {
            point[0]=face.getLeftEyePosition().x - delta_x / 2;
            point[1]=face.getLeftEyePosition().y;
            point[2]=face.getLeftEyePosition().x + delta_x / 2;
            point[3]=face.getLeftEyePosition().y;
          }
          bsgcTranslateMatrix.mapPoints(point);
          mMatrix.mapPoints(point);
          if (exFace.getLeyeBlink() >= blink_threshold) {
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (face.getRightEyePosition() != null) {
          if ((mDisplayRotation == 0) || (mDisplayRotation == 180)) {
            point[0]=face.getRightEyePosition().x;
            point[1]=face.getRightEyePosition().y - delta_y / 2;
            point[2]=face.getRightEyePosition().x;
            point[3]=face.getRightEyePosition().y + delta_y / 2;
          }
 else {
            point[0]=face.getRightEyePosition().x - delta_x / 2;
            point[1]=face.getRightEyePosition().y;
            point[2]=face.getRightEyePosition().x + delta_x / 2;
            point[3]=face.getRightEyePosition().y;
          }
          bsgcTranslateMatrix.mapPoints(point);
          mMatrix.mapPoints(point);
          if (exFace.getReyeBlink() >= blink_threshold) {
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (exFace.getLeftrightGaze() != 0 || exFace.getTopbottomGaze() != 0) {
          double length=Math.sqrt((face.getLeftEyePosition().x - face.getRightEyePosition().x) * (face.getLeftEyePosition().x - face.getRightEyePosition().x) + (face.getLeftEyePosition().y - face.getRightEyePosition().y) * (face.getLeftEyePosition().y - face.getRightEyePosition().y)) / 2.0;
          double nGazeYaw=-exFace.getLeftrightGaze();
          double nGazePitch=-exFace.getTopbottomGaze();
          float gazeRollX=(float)((-Math.sin(nGazeYaw / 180.0 * Math.PI) * Math.cos(-exFace.getRollDirection() / 180.0 * Math.PI) + Math.sin(nGazePitch / 180.0 * Math.PI) * Math.cos(nGazeYaw / 180.0 * Math.PI) * Math.sin(-exFace.getRollDirection() / 180.0 * Math.PI)) * (-length) + 0.5);
          float gazeRollY=(float)((Math.sin(-nGazeYaw / 180.0 * Math.PI) * Math.sin(-exFace.getRollDirection() / 180.0 * Math.PI) - Math.sin(nGazePitch / 180.0 * Math.PI) * Math.cos(nGazeYaw / 180.0 * Math.PI) * Math.cos(-exFace.getRollDirection() / 180.0 * Math.PI)) * (-length) + 0.5);
          if (exFace.getLeyeBlink() < blink_threshold) {
            if ((mDisplayRotation == 90) || (mDisplayRotation == 270)) {
              point[0]=face.getLeftEyePosition().x;
              point[1]=face.getLeftEyePosition().y;
              point[2]=face.getLeftEyePosition().x + gazeRollX;
              point[3]=face.getLeftEyePosition().y + gazeRollY;
            }
 else {
              point[0]=face.getLeftEyePosition().x;
              point[1]=face.getLeftEyePosition().y;
              point[2]=face.getLeftEyePosition().x + gazeRollY;
              point[3]=face.getLeftEyePosition().y + gazeRollX;
            }
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
          if (exFace.getReyeBlink() < blink_threshold) {
            if ((mDisplayRotation == 90) || (mDisplayRotation == 270)) {
              point[0]=face.getRightEyePosition().x;
              point[1]=face.getRightEyePosition().y;
              point[2]=face.getRightEyePosition().x + gazeRollX;
              point[3]=face.getRightEyePosition().y + gazeRollY;
            }
 else {
              point[0]=face.getRightEyePosition().x;
              point[1]=face.getRightEyePosition().y;
              point[2]=face.getRightEyePosition().x + gazeRollY;
              point[3]=face.getRightEyePosition().y + gazeRollX;
            }
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
        }
        if (face.getMouthPosition() != null) {
          Log.e(TAG,"String_Node_Str" + exFace.getSmileDegree() + "String_Node_Str"+ exFace.getSmileConfidence());
          if (exFace.getSmileDegree() < smile_threashold_no_smile) {
            point[0]=face.getMouthPosition().x + dx - delta_x;
            point[1]=face.getMouthPosition().y;
            point[2]=face.getMouthPosition().x + dx + delta_x;
            point[3]=face.getMouthPosition().y;
            Matrix faceMatrix=new Matrix();
            faceMatrix.preRotate(exFace.getRollDirection(),face.getMouthPosition().x,face.getMouthPosition().y);
            faceMatrix.mapPoints(point);
            bsgcTranslateMatrix.mapPoints(point);
            mMatrix.mapPoints(point);
            canvas.drawLine(point[0] + dx,point[1] + dy,point[2] + dx,point[3] + dy,mPaint);
          }
 else           if (exFace.getSmileDegree() < smile_threashold_small_smile) {
            int rotation_mouth=360 - mDisplayRotation;
            mRect.set(face.getMouthPosition().x - delta_x,face.getMouthPosition().y - delta_y,face.getMouthPosition().x + delta_x,face.getMouthPosition().y + delta_y);
            bsgcTranslateMatrix.mapRect(mRect);
            mMatrix.mapRect(mRect);
            mRect.offset(dx,dy);
            canvas.drawArc(mRect,rotation_mouth,180,true,mPaint);
          }
 else {
            mRect.set(face.getMouthPosition().x - delta_x,face.getMouthPosition().y - delta_y,face.getMouthPosition().x + delta_x,face.getMouthPosition().y + delta_y);
            bsgcTranslateMatrix.mapRect(mRect);
            mMatrix.mapRect(mRect);
            mRect.offset(dx,dy);
            canvas.drawOval(mRect,mPaint);
          }
        }
      }
    }
    canvas.restore();
  }
  super.onDraw(canvas);
}