public void setObject(Face face) { Log.d( TAG, "[setObject]mZoomInAnimaState:" + mZoomInAnimaState + "" + ", mZoomOutAnimaState:" + mZoomOutAnimaState); if (mZoomInAnimaState == ANIMATION_DOING || mIsClear) { return; } mFace = face; if (mZoomOutAnimaState == ANIMATION_IDLE) { if (face.score == OBJECT_TRACKING_SUCCEED) { showSuccess(true); } else if (face.score == OBJECT_TRACKING_FAILED) { showFail(true); } } else if (mZoomOutAnimaState == ANIMATION_DONE) { Log.i(TAG, "[setObject]invalidate "); resetView(); invalidate(); } }
public void showFail(boolean timeout) { Log.d(TAG, "[showFail]timeout= " + timeout); mIsClear = false; mZoomOutAnimaState = ANIMATION_DOING; mTrackIndicator = mTrackStatusIndicator[OBJECT_FOCUSED]; setBackground(mTrackIndicator); animate() .withLayer() .setDuration(SCALING_DOWN_TIME) .scaleX(0.8f) .scaleY(0.8f) .withEndAction(mEndAction); }
public void showStart() { Log.d(TAG, "[showStart]..."); mIsClear = false; mZoomInAnimaState = ANIMATION_DOING; mZoomOutAnimaState = ANIMATION_IDLE; mTrackIndicator = mTrackStatusIndicator[OBJECT_FOCUSING]; setBackground(mTrackIndicator); animate() .withLayer() .setDuration(SCALING_UP_TIME) .scaleX(1.5f) .scaleY(1.5f) .withEndAction(mStartAction); }
@Override protected void onDraw(Canvas canvas) { Log.d( TAG, "[onDraw]mZoomInAnimaState:" + mZoomInAnimaState + ", mZoomOutAnimaState:" + mZoomOutAnimaState + ", mOrientation:" + mOrientation); if (mZoomOutAnimaState != ANIMATION_DONE || mZoomInAnimaState != ANIMATION_DONE) { return; } if (mFace != null) { if (mFace.score == OBJECT_TRACKING_SUCCEED) { mTrackIndicator = mTrackStatusIndicator[OBJECT_FOCUSED]; } else { Log.i(TAG, "[onDraw]mFace is null."); return; } // Prepare the matrix. Util.prepareMatrix(mMatrix, false, mDisplayOrientation, mUnCropWidth, mUnCropHeight); // OT indicator is directional. Rotate the matrix and the canvas // so it looks correctly in all orientations. float dx = (getWidth() - mUnCropWidth) / 2; float dy = (getHeight() - mUnCropHeight) / 2; Matrix pointMatrix = new Matrix(); float[] pointes = new float[] {dx, dy}; canvas.save(); mMatrix.postRotate(mOrientation); canvas.rotate(-mOrientation); pointMatrix.postRotate(mCompesation); pointMatrix.mapPoints(pointes); // Transform the coordinates. mRect.set(mFace.rect); mMatrix.mapRect(mRect); mRect.offset(pointes[0], pointes[1]); mTrackIndicator.setBounds( Math.round(mRect.left), Math.round(mRect.top), Math.round(mRect.right), Math.round(mRect.bottom)); if (needDraw()) { mTrackIndicator.draw(canvas); } canvas.restore(); } super.onDraw(canvas); }
public void setDisplayOrientation(int orientation) { mDisplayOrientation = orientation; Log.d(TAG, "mDisplayOrientation=" + orientation); }