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


Java CameraCharacteristics.LENS_FACING_FRONT屬性代碼示例

本文整理匯總了Java中android.hardware.camera2.CameraCharacteristics.LENS_FACING_FRONT屬性的典型用法代碼示例。如果您正苦於以下問題:Java CameraCharacteristics.LENS_FACING_FRONT屬性的具體用法?Java CameraCharacteristics.LENS_FACING_FRONT怎麽用?Java CameraCharacteristics.LENS_FACING_FRONT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.hardware.camera2.CameraCharacteristics的用法示例。


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

示例1: createCamera

@Override
protected String createCamera(int deviceDegrees) throws CameraException {
    try {
        for (String camId : mCamManager.getCameraIdList()) {
            CameraCharacteristics characteristics = mCamManager.getCameraCharacteristics(camId);
            Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);

            if (facing == CameraCharacteristics.LENS_FACING_FRONT) {
                Log.d(TAG, "front-facing mCamera found: " + camId);
                return camId;
            }
        }
    } catch (CameraAccessException e) {
        throw new CameraException(e);
    }

    throw new CameraException(mActivity.getString(R.string.frontCameraMissing));
}
 
開發者ID:vbier,項目名稱:habpanelviewer,代碼行數:18,代碼來源:MotionDetectorCamera2.java

示例2: sensorToDeviceRotation

/**
 * Rotation need to transform from the camera sensor orientation to the device's current
 * orientation.
 *
 * @param c                 the {@link CameraCharacteristics} to query for the camera sensor
 *                          orientation.
 * @param deviceOrientation the current device orientation relative to the native device
 *                          orientation.
 * @return the total rotation from the sensor orientation to the current device orientation.
 */
private static int sensorToDeviceRotation(CameraCharacteristics c, int deviceOrientation) {
    int sensorOrientation = c.get(CameraCharacteristics.SENSOR_ORIENTATION);

    // Get device orientation in degrees
    deviceOrientation = ORIENTATIONS.get(deviceOrientation);

    // Reverse device orientation for front-facing cameras
    if (c.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
        deviceOrientation = -deviceOrientation;
    }

    // Calculate desired JPEG orientation relative to camera orientation to make
    // the image upright relative to the device orientation
    return (sensorOrientation + deviceOrientation + 360) % 360;
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:25,代碼來源:Camera2Fragment.java

示例3: sensorToDeviceRotation

/**
 * Rotation need to transform from the camera sensor orientation to the device's current
 * orientation.
 *
 * @param c                 the {@link CameraCharacteristics} to query for the camera sensor
 *                          orientation.
 * @param deviceOrientation the current device orientation relative to the native device
 *                          orientation.
 * @return the total rotation from the sensor orientation to the current device orientation.
 */
public static int sensorToDeviceRotation(CameraCharacteristics c, int deviceOrientation) {
    int sensorOrientation = c.get(CameraCharacteristics.SENSOR_ORIENTATION);

    // Get device orientation in degrees
    deviceOrientation = ORIENTATIONS.get(deviceOrientation);

    // Reverse device orientation for front-facing cameras
    if (c.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
        deviceOrientation = -deviceOrientation;
    }

    // Calculate desired JPEG orientation relative to camera orientation to make
    // the image upright relative to the device orientation
    return (sensorOrientation + deviceOrientation + 360) % 360;
}
 
開發者ID:OkayCamera,項目名稱:OkayCamera-Android,代碼行數:25,代碼來源:Utils.java

示例4: toggleFacing

public void toggleFacing() {
  if (facingSelected == CameraCharacteristics.LENS_FACING_FRONT) {
    facingSelected = CameraCharacteristics.LENS_FACING_BACK;
    toggleButton.setImageResource(R.drawable.ic_camera_rear);
  } else {
    facingSelected = CameraCharacteristics.LENS_FACING_FRONT;
    toggleButton.setImageResource(R.drawable.ic_camera_front);
  }

  toggleButton.invalidate();

  closeCamera();
  if (textureView.isAvailable()) {
    openCamera(textureView.getWidth(), textureView.getHeight());
  } else {
    textureView.setSurfaceTextureListener(surfaceTextureListener);
  }
}
 
開發者ID:flipper83,項目名稱:SortingHatAndroid,代碼行數:18,代碼來源:CameraConnectionFragment.java

示例5: initializeCameraManager

@Override
public void initializeCameraManager(ConfigurationProvider configurationProvider, Context context) {
    super.initializeCameraManager(configurationProvider, context);

    this.manager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);

    final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    final Display display = windowManager.getDefaultDisplay();
    final Point size = new Point();
    display.getSize(size);
    windowSize = new Size(size.x, size.y);

    try {
        final String[] ids = manager.getCameraIdList();
        numberOfCameras = ids.length;
        for (String id : ids) {
            final CameraCharacteristics characteristics = manager.getCameraCharacteristics(id);

            final int orientation = characteristics.get(CameraCharacteristics.LENS_FACING);
            if (orientation == CameraCharacteristics.LENS_FACING_FRONT) {
                faceFrontCameraId = id;
                faceFrontCameraOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
                frontCameraCharacteristics = characteristics;
            } else {
                faceBackCameraId = id;
                faceBackCameraOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
                backCameraCharacteristics = characteristics;
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Error during camera init");
    }
}
 
開發者ID:florent37,項目名稱:CameraFragment,代碼行數:33,代碼來源:Camera2Manager.java

示例6: chooseCamera

private String chooseCamera() {
  final CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
  try {
    for (final String cameraId : manager.getCameraIdList()) {
      final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);

      // We don't use a front facing camera in this sample.
      final Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
      if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) {
        continue;
      }

      final StreamConfigurationMap map =
          characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

      if (map == null) {
        continue;
      }

      useCamera2API = isHardwareLevelSupported(characteristics,
          CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
      LOGGER.i("Camera API lv2?: %s", useCamera2API);
      return cameraId;
    }
  } catch (CameraAccessException e) {
    LOGGER.e(e, "Not allowed to access camera");
  }

  return null;
}
 
開發者ID:Nilhcem,項目名稱:tensorflow-classifier-android,代碼行數:30,代碼來源:CameraActivity.java

示例7: getCameraId

private String getCameraId() throws CameraAccessException {
    int camera = frontFacingCameraActive ? CameraCharacteristics.LENS_FACING_FRONT
                                         : CameraCharacteristics.LENS_FACING_BACK;
    for (String cameraId : cameraManager.getCameraIdList()) {
        CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);

        if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
                == camera) {
            return cameraId;
        }
    }
    return null;
}
 
開發者ID:team-supercharge,項目名稱:SCCameraView,代碼行數:13,代碼來源:Camera2View.java

示例8: getFrontFacingCameraId

@Nullable
private String getFrontFacingCameraId() throws CameraAccessException {
    for (String cameraId : manager.getCameraIdList()) {
        try {
            if (cameraCharacteristicsHelper.getLensFacing(cameraId) == CameraCharacteristics.LENS_FACING_FRONT) {
                return cameraId;
            }
        } catch (CameraException e) {
            // could not determine lens facing characteristic -> continue
        }
    }
    return null;
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:13,代碼來源:CameraHelper.java

示例9: getCameraResolutionsFront

public Size[] getCameraResolutionsFront() {
  try {
    CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics("0");
    if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
        != CameraCharacteristics.LENS_FACING_FRONT) {
      cameraCharacteristics = cameraManager.getCameraCharacteristics("1");
    }
    StreamConfigurationMap streamConfigurationMap =
        cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    return streamConfigurationMap.getOutputSizes(SurfaceTexture.class);
  } catch (CameraAccessException e) {
    Log.e(TAG, e.getMessage());
    return new Size[0];
  }
}
 
開發者ID:pedroSG94,項目名稱:rtmp-rtsp-stream-client-java,代碼行數:15,代碼來源:Camera2ApiManager.java

示例10: toggleCamera

private void toggleCamera() {
  Integer lens = mCamera.getCurrentLensFacing();
  switch (lens) {
    case CameraCharacteristics.LENS_FACING_FRONT:
      mCamera.openCamera(CameraCharacteristics.LENS_FACING_BACK);
      break;
    case CameraCharacteristics.LENS_FACING_BACK:
      mCamera.openCamera(CameraCharacteristics.LENS_FACING_FRONT);
      break;
  }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:11,代碼來源:CameraMenuFragment.java

示例11: initCameraAndPreview

private void initCameraAndPreview() {
    Log.i(TAG, "initCameraAndPreview: is called");

    HandlerThread handlerThread = new HandlerThread("Camera2");
    handlerThread.start();
    mHandler = new Handler(handlerThread.getLooper());

    mCameraId = CameraCharacteristics.LENS_FACING_FRONT + "";
    mImageReader = ImageReader.newInstance(
            mSurfaceView.getWidth(),
            mSurfaceView.getHeight(),
            ImageFormat.JPEG,
            7 /* maxImages */
    );
    mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
        @Override
        public void onImageAvailable(ImageReader reader) {

        }
    }, mHandler);

    RequestPermissions.requestRuntimePermission(
            getActivity(),
            new String[]{Manifest.permission.CAMERA},
            new RequestPermissions.OnRequestPermissionsListener() {
                @Override
                public void onGranted() {
                    try {
                        if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                            return;
                        }
                        mCameraManager.openCamera(mCameraId, deviceStateCallback, mHandler);
                    } catch (CameraAccessException e) {
                        Log.e(TAG, "initCameraAndPreview: open camera failed", e);
                    }
                }

                @Override
                public void onDenied(List<String> deniedPermission) {

                }
            });


}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:45,代碼來源:MyCamera2Fragment.java


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