當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。