当前位置: 首页>>代码示例>>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;未经允许,请勿转载。