对焦过程不拍照的实现---mtk

        之前用户经常有反馈手机拍照模糊,但我们自己根据用户的场景测试发现拍照并不会像用户说的那样拍照模糊,经过反复测试对比等,发现很可能是用户不太留意对焦的问题,拿出手机随机拍照,不会等对焦结束或者对焦清晰后再拍照.为了解决这个问题,想到让用户在对焦过程中不拍照,等对焦完成后再响应用户的拍照动作,因为对焦时间很短,所以并不会给用户感觉拍照有明显的延迟,但会明显减少用户拍照模糊的情况.通过查看代码和log,最终在camera app实现了这个功能,如下就是修改.


autofocus拍照时的判断:

    public void doSnap() {
        Log.i(TAG, "[doSnap]mInitialized =" + mInitialized + " mState=" + mState);
        if (!mInitialized) {
            return;
        }
        // M:
        if (!mListener.readyToCapture()) {
            Log.i(TAG, "[doSnap]readyToCapture is false,return.");
            // In Smile shot mode, enter smile shot processing state
            return;
        }
        // If the user has half-pressed the shutter and focus is completed, we
        // can take the photo right away. If the focus mode is infinity, we can
        // also take the photo.
        if (!needAutoFocusCall() || (mState == STATE_SUCCESS || mState == STATE_FAIL)) {
            capture();
        } else if (mState == STATE_FOCUSING || mAutoFocusMoving==true) {//added by maleijie 20151012 for focusing cap
            // Half pressing the shutter (i.e. the focus button event) will
            // already have requested AF for us, so just request capture on
            // focus here.
//added by ma 20151012 for focusing cap
Log.i(TAG, "[ma]mAutoFocusMoving =" + mAutoFocusMoving);
if(mAutoFocusMoving){ 
mIsNeedCap=mIsNeedCap+1;
if(mIsNeedCap>=2) {
Log.i(TAG, "[ma]mIsNeedCap >= 2,start capture..");
//mIsNeedCap=0; 
capture();
}
}

            else mState = STATE_FOCUSING_SNAP_ON_FINISH;
//mState = STATE_FOCUSING_SNAP_ON_FINISH;
//add end
        } else if (mState == STATE_IDLE) {
            // We didn't do focus. This can happen if the user press focus key
            // while the snapshot is still in progress. The user probably wants
            // the next snapshot as soon as possible, so we just do a snapshot
            // without focusing again.
            capture();
            
        }
    }

对焦时af move的回调:

    public void onAutoFocusMoving(boolean moving) {
        Log.i(TAG, "onAutoFocusMoving = " + moving);
        MMProfileManager.triggerContinueAutoFocus();
        // Ignore if the camera has detected some faces.
        if ((getFrameview() != null && getFrameview().faceExists())) {
            return;
        }
        
        // Ignore if we have requested autofocus. This method only handles
        // continuous autofocus.
        if (mState != STATE_IDLE && mState != STATE_UNKNOWN) {
            Log.i(TAG, "[onAutoFocusMoving]return,mState = " + mState);
            return;
        }
        
        // if current focus mode is INFINISTY, then don't show AF box
        if (Parameters.FOCUS_MODE_INFINITY.equals(getCurrentFocusMode(mContext))) {
            Log.i(TAG, "[onAutoFocusMoving]return,current focus mode is INFINISTY.");
            return;
        }
        mListener.setFocusParameters();
        if (moving) {
//added by ma 20151012 for focusing cap
mAutoFocusMoving=true;
//add end

            mFocusIndicatorRotateLayout.showStart();
        } else {
//added by ma 20151012 for focusing cap
mAutoFocusMoving=false;
if(mIsNeedCap==1) {
Log.i(TAG, "[ma]mIsNeedCap true,start capture..");
mIsNeedCap=0;
capture();
}else{
if(mIsNeedCap!=0){
Log.i(TAG, "[ma]mIsNeedCap "+mIsNeedCap+">=2,mAutoFocusMoving is false,cancel capture..");
mIsNeedCap=0;
}
}
//add end

            mFocusIndicatorRotateLayout.showSuccess(true);
        }
    }



touch af时,对焦不拍照:

  private void onShutterButtonClick() {
     boolean isEnoughSpace = mIFileSaver.isEnoughSpace();
     Log.i(TAG, "[onShutterButtonClick]isEnoughSpace = " + isEnoughSpace + ",mCameraClosed = "
              + mCameraClosed + ",mCurrentState = " + getModeState());
       // Do not take the picture if there is not enough storage.
       if (!isEnoughSpace || mCameraClosed || (ModeState.STATE_IDLE != getModeState() 
&& ModeState.STATE_FOCUSING != getModeState())) {
          Log.w(TAG, "[onShutterButtonClick]return.");//added by ma 20151012 for focusing cap
         return;
       }
       Log.i(TAG,
        "[CMCC Performance test][Camera][Camera] camera capture start ["
                     + System.currentTimeMillis() + "]");
       if (mIFocusManager != null) {
           mIFocusManager.focusAndCapture();
       }
 }

备注:

相机对焦过程不拍照的功能在识别到人脸后反复拍照出现不能拍照的情况:
本来马达动和不动都会上报消息给上层,但人脸识别的时候拍照,概率性马达不动的消息不会上报给上层,导致上层一直认为马达一直在动
按一般情况,马达动的时间很短.,用户在马达动的过程中,不会遇到两次拍照, 检测到两次在马达动的过程中拍照,就认为出现这个情况,这时就会马上拍照,此后每次点击都会拍照.

优化对焦框:---一个是对焦框大小,一个是对焦框动画播放时间, 主要考虑是,对焦动画干脆利落会对用户的体验很好,感觉对焦很快很准的感受.

packages / apps / Camera / src / com / android / camera / ui / FocusIndicatorRotateLayout.java



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值