当前位置: 首页>>代码示例>>Java>>正文


Java CameraCharacteristics.get方法代码示例

本文整理汇总了Java中android.hardware.camera2.CameraCharacteristics.get方法的典型用法代码示例。如果您正苦于以下问题:Java CameraCharacteristics.get方法的具体用法?Java CameraCharacteristics.get怎么用?Java CameraCharacteristics.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.camera2.CameraCharacteristics的用法示例。


在下文中一共展示了CameraCharacteristics.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
public void open() {
    try {
        CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
        for (String cameraId : manager.getCameraIdList()) {
            CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
            if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK) {
                StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                mCameraSize = map.getOutputSizes(SurfaceTexture.class)[0];

                HandlerThread thread = new HandlerThread("OpenCamera");
                thread.start();
                Handler backgroundHandler = new Handler(thread.getLooper());

                manager.openCamera(cameraId, mCameraDeviceCallback, null);

                // カメラの物理的な情報を得る
                mCameraCharacteristics = manager.getCameraCharacteristics( cameraId );
                return;
            }
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:25,代码来源:Camera2.java

示例2: isSupported

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
/**
 * Checks if API is supported and all cameras have better than legacy support.
 */
public static boolean isSupported(Context context) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    return false;
  }

  CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIds = cameraManager.getCameraIdList();
    for (String id : cameraIds) {
      CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(id);
      if (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)
          == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
        return false;
      }
    }
    // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a
    // catch statement with an Exception from a newer API, even if the code is never executed.
    // https://code.google.com/p/android/issues/detail?id=209129
  } catch (/* CameraAccessException */ AndroidException e) {
    Logging.e(TAG, "Camera access exception: " + e);
    return false;
  }
  return true;
}
 
开发者ID:Piasy,项目名称:VideoCRE,代码行数:28,代码来源:Camera2Enumerator.java

示例3: needSwappedDimensions

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
/**
 * Find out if we need to swap dimensions to get the preview size relative to sensor coordinate.
 * @param activity - The associated activity from which the camera is loaded.
 * @param characteristics - CameraCharacteristics corresponding to the current started cameradevice
 * @return swappedDimensions - A boolean value indicating if the the dimensions need to be swapped.
 */
public static boolean needSwappedDimensions(Activity activity, CameraCharacteristics characteristics) {
    int displayRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    //noinspection ConstantConditions
    int mSensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
    boolean swappedDimensions = false;
    switch (displayRotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_90:
            if (mSensorOrientation == 90 || mSensorOrientation == 270) {
                swappedDimensions = true;
            }
            break;
        case Surface.ROTATION_180:
        case Surface.ROTATION_270:
            if (mSensorOrientation == 0 || mSensorOrientation == 180) {
                swappedDimensions = true;
            }
            break;
        default:
            Log.e(TAG, "Display rotation is invalid: " + displayRotation);
    }
    return swappedDimensions;
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:30,代码来源:CameraFragmentUtil.java

示例4: getOrThrow

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
@NonNull
private <T> T getOrThrow(@NonNull String cameraId, @NonNull CameraCharacteristics.Key<T> key) {
    try {
        CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);

        T value = characteristics.get(key);

        if (value == null) {
            throw new CameraException("could not determine camera characteristic " + key.getName() + " from camera " + cameraId);
        } else {
            return value;
        }
    } catch (CameraAccessException e) {
        throw new CameraException(e);
    }
}
 
开发者ID:BioID-GmbH,项目名称:BWS-Android,代码行数:17,代码来源:CameraCharacteristicsHelper.java

示例5: isBackFacing

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
@Override
public boolean isBackFacing(String deviceName) {
  CameraCharacteristics characteristics = getCameraCharacteristics(deviceName);

  return characteristics != null
      && characteristics.get(CameraCharacteristics.LENS_FACING)
      == CameraMetadata.LENS_FACING_BACK;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:9,代码来源:Camera2Enumerator.java

示例6: isHardwareLevelSupported

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
private boolean isHardwareLevelSupported(
    CameraCharacteristics characteristics, int requiredLevel) {
  int deviceLevel = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
  if (deviceLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
    return requiredLevel == deviceLevel;
  }
  // deviceLevel is not LEGACY, can use numerical sort
  return requiredLevel <= deviceLevel;
}
 
开发者ID:Nilhcem,项目名称:tensorflow-classifier-android,代码行数:10,代码来源:CameraActivity.java

示例7: chooseCamera

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
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,代码行数:31,代码来源:CameraActivity.java

示例8: getCameraId

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
private String getCameraId() throws CameraAccessException {
    String[] ids = mCameraManager.getCameraIdList();
    for (String id : ids) {
        CameraCharacteristics c = mCameraManager.getCameraCharacteristics(id);
        Boolean flashAvailable = c.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
        Integer lensFacing = c.get(CameraCharacteristics.LENS_FACING);
        if (flashAvailable != null && flashAvailable
                && lensFacing != null && lensFacing == CameraCharacteristics.LENS_FACING_BACK) {
            return id;
        }
    }
    return null;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:14,代码来源:FlashlightController.java

示例9: cropRegionForZoom

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
/**
 * Calculates sensor crop region for a zoom level (zoom >= 1.0).
 *
 * @return Crop region.
 */
public static Rect cropRegionForZoom(CameraCharacteristics characteristics, float zoom) {
    Rect sensor = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
    int xCenter = sensor.width() / 2;
    int yCenter = sensor.height() / 2;
    int xDelta = (int) (0.5f * sensor.width() / zoom);
    int yDelta = (int) (0.5f * sensor.height() / zoom);
    return new Rect(xCenter - xDelta, yCenter - yDelta, xCenter + xDelta, yCenter + yDelta);
}
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:14,代码来源:AutoFocusHelper.java

示例10: isFrontFacing

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
@Override
public boolean isFrontFacing(String deviceName) {
  CameraCharacteristics characteristics = getCameraCharacteristics(deviceName);

  return characteristics != null
      && characteristics.get(CameraCharacteristics.LENS_FACING)
      == CameraMetadata.LENS_FACING_FRONT;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:9,代码来源:Camera2Enumerator.java

示例11: getCameraId

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
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,代码行数:14,代码来源:Camera2View.java

示例12: getCameraResolutionsFront

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
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,代码行数:16,代码来源:Camera2ApiManager.java

示例13: startCamera

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
@Override
    public void startCamera() {
        try {
            CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraID);
            StreamConfigurationMap configMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

            int width = textureView.getWidth();
            int height = textureView.getHeight();

            //设置一个合适的预览尺寸,防止图像拉伸
//            previewSize = getPreferredPreviewSize(configMap.getOutputSizes(SurfaceTexture.class), width, height);
            previewSize = Util.getPreferredPreviewSize(configMap.getOutputSizes(ImageFormat.JPEG), width, height);
            surfaceTexture.setDefaultBufferSize(previewSize.getWidth(),previewSize.getHeight());
            Log.i(TAG, "previewSize info:" + previewSize.getWidth() + "x" + previewSize.getHeight());

            surface = new Surface(surfaceTexture);

            builder =cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);

            if (surface.isValid()) {
                builder.addTarget(surface);
            }
            Log.i(TAG, "mTextureView info:" + textureView.getWidth() + "x" + textureView.getHeight());

            cameraDevice.createCaptureSession(Arrays.asList(surface),sessionStateCallback,null);

        } catch (CameraAccessException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:lazyparser,项目名称:xbot_head,代码行数:31,代码来源:InteractionFragment.java

示例14: getJPEGOrientation

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
public static int getJPEGOrientation(int rotation, CameraCharacteristics cameraCharacteristics) {
    Integer sensorOrientation = cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
    sensorOrientation = sensorOrientation == null ? 0 : sensorOrientation;
    // Sensor orientation is 90 for most devices, or 270 for some devices (eg. Nexus 5X)
    // We have to take that into account and rotate JPEG properly.
    // For devices with orientation of 90, we simply return our mapping from ORIENTATIONS.
    // For devices with orientation of 270, we need to rotate the JPEG 180 degrees.
    return (ORIENTATIONS.get(rotation) + sensorOrientation + 270) % 360;
}
 
开发者ID:gengqifu,项目名称:361Camera,代码行数:10,代码来源:CameraUtil.java

示例15: getAvailableModeList

import android.hardware.camera2.CameraCharacteristics; //导入方法依赖的package包/类
@Override
public int[] getAvailableModeList(CameraCharacteristics characteristics) {
    return characteristics.get(TONEMAP_AVAILABLE_TONE_MAP_MODES);
}
 
开发者ID:OkayCamera,项目名称:OkayCamera-Android,代码行数:5,代码来源:TonemapComponent.java


注:本文中的android.hardware.camera2.CameraCharacteristics.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。