當前位置: 首頁>>代碼示例>>Java>>正文


Java CameraMetadata類代碼示例

本文整理匯總了Java中android.hardware.camera2.CameraMetadata的典型用法代碼示例。如果您正苦於以下問題:Java CameraMetadata類的具體用法?Java CameraMetadata怎麽用?Java CameraMetadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CameraMetadata類屬於android.hardware.camera2包,在下文中一共展示了CameraMetadata類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: unlockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        setAutoFlash(mPreviewRequestBuilder);
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
                mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
                mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:vulovicv23,項目名稱:opencv-documentscanner-android,代碼行數:21,代碼來源:Camera2BasicFragment.java

示例2: autoFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
public void autoFocus(@Nullable AutoFocusCallback cb, MotionEvent pEvent, int screenW, int screenH) {
    if(cb != null) {
        mAutoFocusCallback = cb;
    }
    if(sensorArraySize != null) {
        final int y = (int)pEvent.getX() / screenW * sensorArraySize.height();
        final int x = (int)pEvent.getY() / screenH * sensorArraySize.width();
        final int halfTouchWidth = 150;
        final int halfTouchHeight = 150;
        MeteringRectangle focusAreaTouch = new MeteringRectangle(
                Math.max(x-halfTouchWidth, 0),
                Math.max(y-halfTouchHeight, 0),
                halfTouchWidth*2,
                halfTouchHeight*2,
                MeteringRectangle.METERING_WEIGHT_MAX - 1);

        try {
            mCaptureSession.stopRepeating();
            //Cancel any existing AF trigger (repeated touches, etc.)
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
            mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);

            //Now add a new AF trigger with focus region
            if(isMeteringAreaAFSupported) {
                mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, new MeteringRectangle[]{focusAreaTouch});
            }
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START);
            mPreviewRequestBuilder.setTag("FOCUS_TAG"); //we'll capture this later for resuming the preview!
            //Then we ask for a single request (not repeating!)
            mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
        } catch(CameraAccessException ex) {
            Log.d("ASD", "AUTO FOCUS EXCEPTION: "+ex);
        }
    }
}
 
開發者ID:EzequielAdrianM,項目名稱:Camera2Vision,代碼行數:39,代碼來源:Camera2Source.java

示例3: unlockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        if(mFlashSupported) {
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, mFlashMode);
        }
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:EzequielAdrianM,項目名稱:Camera2Vision,代碼行數:20,代碼來源:Camera2Source.java

示例4: switchHdrMode

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
private void switchHdrMode() {
    switch (mHdrMode) {
        case 0:
            mHdrMode = 1;
            mIvHdr.setImageResource(R.mipmap.hdr_on);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_HDR);
            break;
        case 1:
            mHdrMode = 0;
            mIvHdr.setImageResource(R.mipmap.hdr_off);
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_DISABLED);
            break;
    }
    try {
        mCaptureSession.setRepeatingRequest(
                mPreviewRequestBuilder.build(),
                mPreCaptureCallback, mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
        return;
    }
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:23,代碼來源:Camera2Fragment.java

示例5: finishedCaptureLocked

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Called after a RAW/JPEG capture has completed; resets the AF trigger state for the
 * pre-capture sequence.
 * <p/>
 * Call this only with {@link #mCameraStateLock} held.
 */
private void finishedCaptureLocked() {
    try {
        // Reset the auto-focus trigger in case AF didn't run quickly enough.
        if (!mNoAFRun) {
            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);

            mCaptureSession.capture(mPreviewRequestBuilder.build(), mPreCaptureCallback,
                    mBackgroundHandler);

            mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                    CameraMetadata.CONTROL_AF_TRIGGER_IDLE);
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:24,代碼來源:Camera2Fragment.java

示例6: start

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
private void start() {
  checkIsOnCameraThread();
  Logging.d(TAG, "start");

  try {
    cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
  } catch (final CameraAccessException e) {
    reportError("getCameraCharacteristics(): " + e.getMessage());
    return;
  }
  cameraOrientation = cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
  isCameraFrontFacing = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
      == CameraMetadata.LENS_FACING_FRONT;

  findCaptureFormat();
  openCamera();
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:18,代碼來源:Camera2Session.java

示例7: unlockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.
 */
private void unlockFocus() {
    try {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
            CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        mPreviewSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
            mBackgroundHandler);

        updateAutoFocus();
        updateFlash(mPreviewRequestBuilder);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
            CaptureRequest.CONTROL_AF_TRIGGER_IDLE);
        mPreviewSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
            mBackgroundHandler);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:lytcom,項目名稱:CameraKitView,代碼行數:25,代碼來源:Camera2Fragment.java

示例8: doPreviewConfiguration

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
private void doPreviewConfiguration() {
        if (mCamera == null) {
            return;
        }

        try {
//            mPreviewBuilder = mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
//            mPreviewBuilder.addTarget(surfaceView.getHolder().getSurface());
//            mPreviewBuilder.addTarget(mImageReader.getSurface());
            mPreviewBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
//            mPreviewBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
//            mPreviewBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);
//            mPreviewBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);

            mPreviewBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, mFps[mFps.length -1 ]);
            mCaptureSession.setRepeatingRequest(mPreviewBuilder.build(), mPreCaptureCallback, mHandler);

        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
 
開發者ID:ThinkKeep,項目名稱:EvilsLive,代碼行數:22,代碼來源:CameraNew.java

示例9: onOpened

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
@Override
public void onOpened(@NonNull CameraDevice camera) {
    mCameraDevice = camera;
    //get builder
    try {
        mBuilder = camera.createCaptureRequest(CameraDevice.TEMPLATE_MANUAL);
        //flash on, default is on
        mBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
        mBuilder.set(CaptureRequest.FLASH_MODE, CameraMetadata.FLASH_MODE_TORCH);
        List<Surface> list = new ArrayList<>();
        SurfaceTexture mSurfaceTexture = new SurfaceTexture(1);
        Size size = getSmallestSize(mCameraDevice.getId());
        mSurfaceTexture.setDefaultBufferSize(size.getWidth(), size.getHeight());
        Surface mSurface = new Surface(mSurfaceTexture);
        list.add(mSurface);
        mBuilder.addTarget(mSurface);
        camera.createCaptureSession(list, new MyCameraCaptureSessionStateCallback(), null);
        mSurfaceTexture.release();
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Abhi347,項目名稱:NoobCameraFlash,代碼行數:23,代碼來源:CameraUtilLollipop.java

示例10: lockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Lock the focus as the first step for a still image capture.
 */
private void lockFocus()
{
    try
    {
        // This is how to tell the camera to lock focus.
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                CameraMetadata.CONTROL_AF_TRIGGER_START);
        // Tell #mCaptureCallback to wait for the lock.
        mState = STATE_WAITING_LOCK;
        mCaptureSession.capture(mPreviewRequestBuilder.build(),
                mCaptureCallback,
                mBackgroundHandler);
    }
    catch(CameraAccessException e)
    {
        LogExt.e(getClass(), e);
    }
}
 
開發者ID:ResearchStack,項目名稱:MoleMapperAndroid,代碼行數:22,代碼來源:LollipopCameraFragment.java

示例11: unlockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Unlock the focus. This method should be called when still image capture sequence is
 * finished.
 */
private void unlockFocus()
{
    try
    {
        // Reset the auto-focus trigger
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        setAutoFlash(mPreviewRequestBuilder);
        mCaptureSession.capture(mPreviewRequestBuilder.build(),
                mCaptureCallback,
                mBackgroundHandler);
        // After this, the camera will go back to the normal state of preview.
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest,
                mCaptureCallback,
                mBackgroundHandler);
    }
    catch(CameraAccessException e)
    {
        LogExt.e(getClass(), e);
        LogExt.e(getClass(), e);
    }
}
 
開發者ID:ResearchStack,項目名稱:MoleMapperAndroid,代碼行數:28,代碼來源:LollipopCameraFragment.java

示例12: unlockFocus

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
private void unlockFocus() {
    try {
        // AFのロックを解除する(トリガーをキャンセルする)
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
                CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
        mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        // AFトリガーのキャンセルを実行する
        mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
                mInterface.getBackgroundHandler());
        // プレビューを継続するためsetRepeatingRequestメソッドを実行する
        mState = STATE_PREVIEW;
        mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureCallback,
                mInterface.getBackgroundHandler());
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:mhidaka,項目名稱:Camera2App,代碼行數:19,代碼來源:BasicCamera.java

示例13: toFile

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Generate a human-readable string of the given capture request and write
 * it to the given file.
 */
public static void toFile(String title, CameraMetadata<?> metadata, File file) {
    try {
        // Will append if the file already exists.
        FileWriter writer = new FileWriter(file, true);
        if (metadata instanceof CaptureRequest) {
            dumpMetadata(title, (CaptureRequest) metadata, writer);
        } else if (metadata instanceof CaptureResult) {
            dumpMetadata(title, (CaptureResult) metadata, writer);
        } else {
            writer.close();
            throw new IllegalArgumentException("Cannot generate debug data from type "
                    + metadata.getClass().getName());
        }
        writer.close();
    } catch (IOException ex) {
        Log.e(TAG, "Could not write capture data to file.", ex);
    }
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:23,代碼來源:CaptureDataSerializer.java

示例14: repeatingPreview

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Request preview capture stream with AF_MODE_CONTINUOUS_PICTURE.
 *
 * @return true if request was build and sent successfully.
 * @param tag
 */
private boolean repeatingPreview(Object tag) {
    try {
        CaptureRequest.Builder builder = mDevice.
                createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        builder.addTarget(mPreviewSurface);
        builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
        addBaselineCaptureKeysToRequest(builder);
        mCaptureSession.setRepeatingRequest(builder.build(), mAutoFocusStateListener,
                mCameraHandler);
        Log.v(TAG, String.format("Sent repeating Preview request, zoom = %.2f", mZoomValue));
        return true;
    } catch (CameraAccessException ex) {
        Log.e(TAG, "Could not access camera setting up preview.", ex);
        return false;
    }
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:23,代碼來源:OneCameraImpl.java

示例15: sendAutoFocusTriggerCaptureRequest

import android.hardware.camera2.CameraMetadata; //導入依賴的package包/類
/**
 * Request preview capture stream with auto focus trigger cycle.
 */
private void sendAutoFocusTriggerCaptureRequest(Object tag) {
    try {
        // Step 1: Request single frame CONTROL_AF_TRIGGER_START.
        CaptureRequest.Builder builder;
        builder = mDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
        builder.addTarget(mPreviewSurface);
        builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
        mControlAFMode = CameraMetadata.CONTROL_AF_MODE_AUTO;
        addBaselineCaptureKeysToRequest(builder);
        builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
        builder.setTag(tag);
        mCaptureSession.capture(builder.build(), mAutoFocusStateListener, mCameraHandler);

        // Step 2: Call repeatingPreview to update mControlAFMode.
        repeatingPreview(tag);
        resumeContinuousAFAfterDelay(FOCUS_HOLD_MILLIS);
    } catch (CameraAccessException ex) {
        Log.e(TAG, "Could not execute preview request.", ex);
    }
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:24,代碼來源:OneCameraImpl.java


注:本文中的android.hardware.camera2.CameraMetadata類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。