Android camera 拍照 流程

APP

347    /**
348     * Take picture, initiating an auto focus scan if needed.
349     */
350    @Override
351    public void takePicture(final PhotoCaptureParameters params, final CaptureSession session) {
352        // Do not do anything when a picture is already requested.
353        if (mTakePictureWhenLensIsStopped) {
354            return;
355        }
356
357        // Not ready until the picture comes back.
358        broadcastReadyState(false);
359
360        mTakePictureRunnable = new Runnable() {
361            @Override
362            public void run() {
363                takePictureNow(params, session);
364            }
365        };
366        mLastPictureCallback = params.callback;
367        mTakePictureStartMillis = SystemClock.uptimeMillis();
368
369        // This class implements a very simple version of AF, which
370        // only delays capture if the lens is scanning.
371        if (mLastResultAFState == AutoFocusState.ACTIVE_SCAN) {
372            Log.v(TAG, "Waiting until scan is done before taking shot.");
373            mTakePictureWhenLensIsStopped = true;
374        } else {
375            // We could do CONTROL_AF_TRIGGER_START and wait until lens locks,
376            // but this would slow down the capture.
377            takePictureNow(params, session);
378        }
379    }
380
381    /**
382     * Take picture immediately. Parameters passed through from takePicture().
383     */
384    public void takePictureNow(PhotoCaptureParameters params, CaptureSession session) {
385        long dt = SystemClock.uptimeMillis() - mTakePictureStartMillis;
386        Log.v(TAG, "Taking shot with extra AF delay of " + dt + " ms.");
387        try {
388            // JPEG capture.

//TEMPLATE_STILL_CAPTURE 表示当前创建的request是拍照
389            CaptureRequest.Builder builder = mDevice
390                    .createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
391            builder.setTag(RequestTag.CAPTURE);
392            addBaselineCaptureKeysToRequest(builder);
393
394            // Enable lens-shading correction for even better DNGs.
395            if (sCaptureImageFormat == ImageFormat.RAW_SENSOR) {
396                builder.set(CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE,
397                        CaptureRequest.STATISTICS_LENS_SHADING_MAP_MODE_ON);
398           
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值